Problem/Motivation
Update mglaman/phpstan-drupal to latest version.
mglaman/phpstan-drupal 1.1.9 1.1.16 Drupal extension and rules for PHPStan
Proposed resolution
Update.
Regenerate baseline.
Check added issues, and see if they need to be fixed.
Opened #3280071: [PP-1 Upstream] Clean-up (if still around) false positive on PHPStan "Missing explicit access check on entity query." to clean up the introduced false positives on access checks from the baseline. Postponed in on a new phpstan-drupal release which might fix more false-positives.
We decided to disable the check for access checks on entity queries until there's a release that works without issues. Opened #3280328: Stop ignoring "Missing explicit access check on entity query." rule in core/phpstan-baseline.neon as a follow-up for that.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3279840
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
spokjeComment #4
spokjeLooks
mglaman/phpstan-drupal:1.1.16like came with a new "Missing explicit access check on entity query." check.Let's try to fix the new suppressions for that in here.
Comment #5
mallezieMR looks good to me. Only removals in the phpstan-baseline. (Aside from entity access check).
@Spokje, do you mean clean the access checks in this issue? Or do a followup? (In general i would say, clean it here, and never add things to the baseline, on the other hand, the update is critical, but removal of the new issues might be not, although this could also be defined critical as in being security-improvements).
What's the core policy on
This got into the composer update (probably because spokje's compers version is higher then the one from drupal core).
Comment #6
spokje@mallezie:
In here, like you also suggesting :)
I think I can get those fixed within the next couple of hours, which is (IMHO) good enough for even a Critical?
If not: Let me know and we'll fix it in a follow-up.
Indeed my mistake, not sure the policy, but I've reverted it whilst working on solving the access checks.
Comment #7
mallezieSounds great to me! Happy to review (tomorrow).
It's a critical, but not a 'everything is broken and we need to release D10 tomorrow'-critical ;-)
Comment #8
spokjeThanks, I kinda like non-critical criticals... 😇
Comment #9
spokjeOk, so this release brings _a lot_ of false positives on
Missing explicit access check on entity query.(See comments in MR, https://github.com/mglaman/phpstan-drupal/issues/396 and https://drupal.slack.com/archives/C033S2JUMLJ/p1652274305914599?thread_t...)
If (and only if) this is all this release brings to the table, I would *not* recommend shipping it with drupal/core, but rather wait on a release that has much less noise.
However, I think this release also would considerably decrease mem-usage when doing a full file run. If this is the case, I would say: Use the current MR, leave all new suppressions in the baseline to make #3259355: Always do a full phpstan analysis on DrupalCI happen, and deal with the false positives when a new release comes out (which hopefully has less of those).
Putting this on NR to get more eyes/brains/random-body-parts on this.
Comment #10
mallezieWent through the releases and i don't think mglaman/phpstan-drupal updates bring memory improvements on itself.
Updating phpstan/phpstan brings some, which is why this was split of to update in #3278916: Update phpstan/phpstan to latest version.
IMO i would say commit this (but needs reroll, since the out-of-sync-baseline issues are in). Add those items to the baseline.
Then postpone the access checks cleanup from the baseline to a follow-up phpstan-drupal release which might fix more false-positives.
Comment #11
spokjeThanks @mallezie, was just doing the required reroll as you were typing.
I can live with that :)
Opened #3280071: [PP-1 Upstream] Clean-up (if still around) false positive on PHPStan "Missing explicit access check on entity query." for the (hoepfully not needed) cleanup of the baseline when a new version is released
Comment #12
spokje(Opened https://github.com/mglaman/phpstan-drupal/issues/406 for the Windows vs POSIX issue that now bit me twice)
Comment #13
spokjeReroll managed to scrape by The Land Of JSTestFailure-Doom. Needs Review
Comment #14
mallezieLooks good to me. Only adds entity query Access checks to the baseline. Cleans up some false positives fixed by the update, and foxes one new entry found (the random thing).
Comment #15
spokjeThanks @mallezie.
Just realized the fix (and the fix only) should be backported down to
9.3.x-dev. Adding patch for that.Comment #16
mallezieThere do seem to be some quite good performance improvement in this upgrade.
From #3259355: Always do a full phpstan analysis on DrupalCI
https://www.drupal.org/project/drupal/issues/3259355#comment-14409270
In this issue a full scan takes 1:15
While in #3278916: Update phpstan/phpstan to latest version a full scan takes 2:27
Crossposting this also to #3259355: Always do a full phpstan analysis on DrupalCI
Comment #17
alexpottThis can't be a critical issue. It does not meet any of the requirements for one laid here - https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...
Also I think we should fix the broken code in a way that does less. Let's make people supply the title - they have to do that today because it is broken - and we don't know that because we don't use it.
Comment #18
alexpottAlso the fix to \Drupal\Tests\quickedit\FunctionalJavascript\SettingsTrayIntegrationTest::createBlockContent() needs to be backported to 9.x
Comment #19
spokjeChanging patch/MR.
You might have missed the patch in #15 which does just that?
Anyway, that will be adapted to the solution in your first quote.
Also this needs to be backported to the Contrib QuickEdit, for which I already created #3280145: Invalid/outdated code in \Drupal\Tests\quickedit\FunctionalJavascript\SettingsTrayIntegrationTest which I will reroll _after_ we have a commit in this issue
Comment #20
spokjeComment #21
spokjeComment #22
spokjeComment #23
spokjeComment #24
alexpottThanks @Spokje that looks great.
Comment #25
mallezieI can confirm this solves the remarks from alexpott.
Thanks for the priority update, i've marked it originally critical as it was spunoff from #3278162: Update Composer dependencies to the latest minor and patch versions which was critical. But i can perfectly see it's actually not.
Comment #26
alexpottWhen I tried to commit this I got the following reported:
The odd thing is that the node.module actually has 2 entity queries missing the access check - not 1 or 3. They are both in the completely unused in core
node_get_recent(). I think the entity query access checking check must be flawed and I think either we have to disable the rule and get it fixed upstream or we have to get it fixed upstream and then use that new version here.If I remove the error from the baseline completely and re-run phpstan then it tells me...
However here's the lines from node.module around 1090...
So that query is doing it correctly.
I decided to commit #22 to all branches since that is fixing something that is broken and needs a fix in more places than the update and opening a separate issue for it felt meh.
Committed and pushed ce7120d598 to 10.0.x and f88b95826e to 9.5.x and 9af805fa84 to 9.4.x. Thanks!
Comment #30
spokjeSome clean-up after the commits above.
Comment #32
spokjeOpened #3280328: Stop ignoring "Missing explicit access check on entity query." rule in core/phpstan-baseline.neon as a follow-up
Comment #33
spokjeComment #35
mondrakeIgnoring the questionable rule while at the same time bumping the dependency seems to me a sensible approach. https://drupal.slack.com/archives/C1BMUQ9U6/p1652431244395749 for background.
We remove false positives from the baseline thanks to better checks implemented in the latest dependency releases, so all seems good here.
Comment #36
alexpottCommitted 33de6ee and pushed to 10.0.x. Thanks!
Comment #40
spokje