Skip to content

Call to method Drupal\Core\Entity\Query\QueryInterface::accessCheck() will always evaluate to true (PHPStan 2)Β #825

@WalkingDexter

Description

@WalkingDexter

Bug report

After upgrading to PHPStan 2, errors related to the accessCheck() method occurred. A similar problem was previously solved in #508.

Versions used:

  • phpstan/phpstan 2.1.4
  • mglaman/phpstan-drupal 2.0.1

Code snippet that reproduces the problem

// Error: method.alreadyNarrowedType
\Drupal::entityQuery('node')
  ->accessCheck()
  ->execute();

// Error: method.alreadyNarrowedType
\Drupal::entityQuery('node')
  ->accessCheck()
  ->condition('type', 'article')
  ->execute();

// No error.
\Drupal::entityQuery('node')
  ->condition('type', 'article')
  ->accessCheck()
  ->execute();

// Error: method.alreadyNarrowedType
$query = \Drupal::entityQuery('node');
$query->condition('type', 'article');
$query->accessCheck();
$query->execute();

Public example from GitLab CI: https://git.drupalcode.org/project/simple_sitemap/-/jobs/4303395

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions