phpstan-drupal icon indicating copy to clipboard operation
phpstan-drupal copied to clipboard

accessCheck deprecation not detected if query returned from method

Open neclimdul opened this issue 2 years ago • 3 comments

Bug report

This is just the hardest deprecation to detect...

My guess is that because the query is setup in one method but the execution happens in several others the detection is never triggered.

Code snippet that reproduces the problem

I think this should be an accurate example of the problem. I had a helper that setup a base query that was used in several parts of the class to target a specific node type in a specific state.

class Foo {
  public function test1() {
    $this->getNodeQuery()->condition('field_two', 'bugaloo')->execute();
  }

  private function getNodeQuery() {
    return \Drupal::entityQuery('node')
      ->accessCheck(TRUE)
      ->condition('type', 'node_type')
      ->condition('status', 1)
      ->sort('field_publish_date', 'DESC');
  }
}

neclimdul avatar Jun 22 '23 14:06 neclimdul

Similar to https://github.com/mglaman/phpstan-drupal/issues/437

mglaman avatar Jun 22 '23 17:06 mglaman

yeah for sure. Only reported it separate because wasn't sure they could be fixed the same way.

neclimdul avatar Jun 22 '23 22:06 neclimdul

😅 probably definitely not

mglaman avatar Jun 22 '23 22:06 mglaman