Skip to content

EntityQuery accessCheck() false positive if chaining conditions #613

Open
@pfrenssen

Description

@pfrenssen

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions