phpstan-drupal
phpstan-drupal copied to clipboard
fix: Fix unpredictable false positive/negative of missing entity access check in function scope due to cache key conflict
Fixes #475
The EntityQueryType was getting cached in function scope for a condition call and because it wasn't handled by dynamic return it reused. So if you had condition before accessCheck and then later on after it, the latter one could fail because it would return the cached without access check and there would be no subsequent access check (it happens before).
Added test case.
Still examining why this doesn't occur in class scope but it seems phpstan has additional cache key when it is just not sure of its granularity.
It did happen in class scope - PR has tests for both that reproduce and the fix solve
Tested the fix on those false positives that we got reported and the patch did silence them. RTBC
(The pipeline looks broken at this moment, I made an attempt to fix one issue in #485, but other skeletons popped up.)
thanks, everyone!
@mglaman Thanks! I read the two commits and they definitely improvements :)
Really happy this got in - it was a super hard one to track down!!!
Really happy this got in - it was a super hard one to track down!!!
Thanks for tracking this down! It was driving me wild.