EntityQuery accessCheck() false positive if chaining conditions

Aperta
#613 4 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
43/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php

Direzione di ricerca

Start by tracing the rule that detects calls to EntityQuery::accessCheck() and compare how it handles chained calls with the non-chained example in the issue. Add coverage for both chain orderings and confirm the rule no longer reports a false positive when accessCheck(FALSE) is present. The issue does not name the rule or test files, so locate them from the reported deprecation message.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug entity query

Bug report

When an EntityQuery::accessCheck() call is chained with other methods it is not detected.

This is similar to #437 but possibly requires a different fix.

Code snippet that reproduces the problem

This yields a Relying on entity queries to check access by default is deprecated error:

  $storage = \Drupal::entityTypeManager()->getStorage('node');
  $query = $storage->getQuery();
  $query
    ->accessCheck(FALSE)
    ->condition('field_myfield', TRUE);
  $entity_ids = $query->execute();

The ordering doesn't matter, if the accessCheck() is last, the error still occurs:

  $storage = \Drupal::entityTypeManager()->getStorage('node');
  $query = $storage->getQuery();
  $query
    ->condition('field_myfield', TRUE)
    ->accessCheck(FALSE);
  $entity_ids = $query->execute();

When the calls are not chained, the rule works correctly. This does not yield an error:

  $storage = \Drupal::entityTypeManager()->getStorage('node');
  $query = $storage->getQuery();
  $query->accessCheck(FALSE);
  $query->condition('field_myfield', TRUE);
  $entity_ids = $query->execute();
Lingua principale
PHP
Stelle
208
Fork
88
Merge medio
2g 6h
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mglaman/phpstan-drupal

Tutte le issue di mglaman/phpstan-drupal

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.