Closed (fixed)
Project:
Drupal core
Version:
10.0.x-dev
Component:
base system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 May 2022 at 17:45 UTC
Updated:
5 Aug 2022 at 16:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mondrakeComment #3
mondrakeComment #4
mondrakeComment #5
mondrakeComment #6
mondrakePHPStan run execution time is going down, from 2 min 30 sec to 1 min 50 sec.
Comment #8
mondrakeComment #9
daffie commentedWhat I am missing is when should exist and when not? I cannot find it in D10 and this patch is for D10. Can we remove the file phpstan-bootstrap.php for D10? If it is needed, can we than add a comment with when the trait exists and when not.
All the other changes look good to me.
Comment #10
alexpottIf I run this patch locally I still get
One of the differences between my environment and DrupalCI is PHP version. DrupalCI is on 8.1.0 and I'm on 8.1.3. Not sure if that is to blame.
I think this is the wrong fix for this problem. The correct fix is to do what Symfony does - see #3282395: Latest versions of PHPStan and mglaman/phpstan-drupal cannot find PhpUnitVersionDependentTestCompatibilityTrait
Comment #11
mondrakePostpone per #3282395-6: Latest versions of PHPStan and mglaman/phpstan-drupal cannot find PhpUnitVersionDependentTestCompatibilityTrait
Comment #12
mondrakeComment #13
mondrakeNeeds reroll after #3282395: Latest versions of PHPStan and mglaman/phpstan-drupal cannot find PhpUnitVersionDependentTestCompatibilityTrait
Comment #14
mondrakeNew patch, for PHPStan 1.7.2 and no baseline removals. Interdiff would be irrelevant.
Comment #15
daffie commentedLooks good to me.
Comment #16
mondrakeThanks @daffie. Unfortunately #10.1 is not solved by the update.
Comment #17
mallezieCould this change also be removed?
Comment #18
alexpott@mondrake and others - does phpstan pass the full analysis locally with #14 or do you get the REQUEST_TIME deprecation baseline changes like DrupalCI?
Trying to work out if it is me or DrupalCI that's being odd.
Comment #19
mondrakeRunning
phpstan analyzeon both1.7.2 --> https://github.com/mondrake/d8-unit/runs/6614280891?check_suite_focus=true
and
1.7.1 --> https://github.com/mondrake/d8-unit/runs/6615559848?check_suite_focus=true
fail miserably on GitHub Actions:
Bah. No idea what's going on.
Comment #20
mondrakeBumped to latest phpstan 1.7.3 and phpstan-drupal 1.1.18; addressed #17.
Comment #21
mondrakeTrying running with
--debugthat prevents parallellization of scans. Running that on GHA, after 2h 12m, I got one of the two errors disappear.Comment #22
mallezieFWIW, just ran both patches, and ran phpstan without any issue (locally).
So the main question is, why does this work with --debug on drupalci, and not with the parallellization. And why on GHA, does this only resolve 1 error, and it does resolve both on drupalCI.It is still running on drupalCI.
Comment #23
mondrakeThere’s a hard limit of 110 min on DrupalCI runs, #21 aborts.
Comment #24
mondrakeTrying to cap the maximum number of subprocesses.
Comment #25
mondrakeComment #26
mondrakeLimit processes to 4
Comment #27
mallezieThe deprecated constant rule comes from phpstan-drupal. So possible there would be something wrong in that rule.
https://github.com/mglaman/phpstan-drupal/blob/main/src/Rules/Deprecatio...
However since we always see the deprecated constant coming up in the same 2 files (comment.module / history.module) we might workaround it, by fixing the deprecations here as well?
Comment #28
alexpottUnfortunately fixing these constants is not that simple. We really need to refactor them both away. See #2006632: Make HISTORY_READ_LIMIT configurable
Comment #29
xjmhttps://www.drupal.org/pift-ci-job/2392768 is also failing because of #10. This is kinda bad because that means it's not testing any other dependency updates since CS checks fail first.
Is #2006632: Make HISTORY_READ_LIMIT configurable supposed to address this? It doesn't seem to.
And it'd be 9.5.x only, but we need to fix HEAD in 9.4.x somehow.Sorry, forgot for a moment that this is a D10-only issue for core.Comment #30
mondrakephpstan 1.7.5 is out, bumping the patch
removing attempts with limited concurrency
Comment #31
mondrakewith
--debugand limiting PHPstan scan to comment and history modules.Comment #32
mondrakeSo #31 shows that on DrupalCI the failure is there also without concurrent scanning.
Comment #33
mallezieThe two errors blocking us are using the constant in a define.
define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
define('COMMENT_NEW_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
Why those are found locally and not on CI is still puzzling me. Guess would be that the reflection provides behaves differently in the minor php-version differences. https://github.com/phpstan/phpstan-src/tree/1.7.x/src/Reflection (But that code is way above my head)
I don't think those are blocked on #2006632: Make HISTORY_READ_LIMIT configurable which is about removing the entire constant.
Let's see if a workaround by just adjusting the defined constant with a non-deprecated constant could work?
Comment #34
mallezieComment #35
mallezieForgot to update baseline.
Comment #36
mallezieAdjusted to $_SERVER[‘REQUEST_TIME’] instead of the container call.
Comment #37
daffie commentedThe patch from comment #35 looks good to me.
Changing REQUEST_TIME in the defined variables COMMENT_NEW_LIMIT and HISTORY_READ_LIMIT to \Drupal::time()->getRequestTime() is good to me.
The PHPStan baseline file has 1 suppression message removed and another happens now only 2 instead of 3 times.
The packages mglaman/phpstan-drupal and phpstan/phpstan are updated.
For me it is RTBC.
For the patch from comment #36: I really do not like adding
$_SERVER[‘REQUEST_TIME’]to Drupal core.Comment #38
mallezieSeems the $_SERVER[‘REQUEST_TIME’] breaks all kinds of tests.
This was suggested by alexpott to give it a try. He also proposed (and pinged mixologic for it) to see if we could first try updating php 8.1 to the latest patch release on DrupalCI to see if that fixes it.
So let's wait a bit on that first.
Comment #39
mondrakeBTW, PHPStan 1.7.6 is out already, so we'd need a further bump.
Comment #40
mondrakeFailure of #36 are due to use of invalid characters (quotation marks ‘REQUEST_TIME’ instead of apostrophes 'REQUEST_TIME'). I think the risk with using the container in a
define()is that it is not yet initialised at the time of loading .module files, but tests seem to indicate otherwise. If that works I think that's preferrable 'cause I think I read somewhere we should avoid accessing global server variables directly and use Symfony proxies instead.Comment #41
alexpottI really don't think that accessing \Drupal from the main of a module file is a not great idea - even if our test coverage is green. I'd rather try and get DrupalCI's PHP updated and see if it is that before changing this code but if we do have to change the code using
$_SERVER['REQUEST_TIME']would, for me, be the way safer way to do this. Hopefully we don't have to touch it.Comment #42
alexpottOpened #3283430: Update PHP 8.1 to latest bugfix release to track updating the PHP 8.1 version
Comment #43
mondrakeJust a basic update patch to reflect latest PHPStan version, misses @mallezie changes in #35
Comment #44
mondrakeRetesting #43 on PHP 8.1.5.
Comment #45
mondrakeStill errors also on PHP 8.1.5.
Time to go for #41?
Comment #46
mallezieUpdated phpstan again, and disabled the RuntimeReflectionProvider to see if that's the one to blame.
Comment #47
mallezieSo seems disabling the ReflectionProvider does not solve.
Updated 41 with latest version of phpstan (there was another updated version just now).
Comment #49
alexpottHere's a silly wild guess...
Comment #50
mondrakeOMG really?
Comment #51
alexpottHere's the update to PHPStan and PHPStan Drupal and the fix :)
Comment #52
mondrakeI think this should be fixed upstream, really, but this can get us going. Also, REQUEST_TIME is actually deprecated so it will be removed at some point. Just to say this is minor for our purposes, relevant to be fixed for the general case upstream.
Comment #53
mondrakeMeantime, PHPStan is at 1.7.10 and PHPStan-Drupal at 1.1.19, do we need to chase?
Comment #54
mallezieUpdated.
There was one rename of a notice in the baseline nothing more.
Going through both release notes, i don't see much changed (on level 0 that is, the stubs can give people some help running on higher levels, if they follow the version of core, and since this is 10.x, this is probably too early).
Both phpstan and phpstan-drupal update a lot (weekly and more) so chasing is not always needed IMO (for patch releases) unless we see performance improvements or fixing of false posisitives.
Comment #55
mondrakeThen I think we should also bump the version constraint in composer.json, otherwise lower versions would report an error.
Comment #56
mallezieUpdated constraints in composer.json
Comment #57
mondrakeThanks @mallezie
Comment #58
alexpottCommitted f50b372 and pushed to 10.0.x. Thanks!
I think the change to how the constants are defined is pragmatic - given that we'd like to completely remove them at some point.
Let's fix the update dependency build wrt to PHPStan...
Comment #60
alexpottHmmm ... I disagree with the change to fixed constants. That makes it harder to update and test the future. This is what lock files are for. Reverted so we can go back to constants that allow this to be upgraded.
Comment #62
mondrakeOh yes sure I missed that... we still need the caret ^ in front, so composer can go up but not down. Meantime... PHPStan 1.7.11 out.
Comment #63
mallezieUpdated again to phpstan 1.7.11 and phpstan-drupal to 1.1.20.
In this latest updates no baseline changes were introduced, so i kept the composer.json constraints on 1.7.10 and 1.1.19 but updated to not lock to those versions. (So used the caret ^).
Comment #64
daffie commentedThe caret ^ characters have been added.
Back to RTBC.
Comment #65
alexpottCommitted dea3a7f and pushed to 10.0.x. Thanks!
Comment #68
alexpottOkay this is very very odd... but it failed once the patch had been committed. See https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/56659/... - this was testing:
But it failed due to:
No idea what's going to make that happen.
Comment #69
mondrakeJust a reroll with latest versions.
Comment #70
mondrakeNow without the changes in comment and history modules.
Comment #71
mondrakeLet's see with PHPStan 1.8.0.
Comment #72
longwaveCould we just add
Call to deprecated constant REQUEST_TIMEto the ignored error list for now? It seems unlikely we are going to solve them all for 10.0.x anyway and they are kinda cluttering up the baseline. We already know it's deprecated and any new uses are unlikely to pass code review.Comment #73
mondrakeComment #74
mondrakeI'm not very keen on #72... exactly because it's so hard to remove usage of this constant, there's a risk of new usage if we just ignore that error.
#73 is doing #41. In the end,
REQUEST_TIMEis defined in bootstrap.inc asI think the endgame is that both
COMMENT_NEW_LIMITandHISTORY_READ_LIMITwould have to be deprecated, replaced by something else object oriented, and finally removed. But that will take probably 3 years. So replacing the usage of REQUEST_TIME in their definitions by the definition of REQUEST_TIME itself should be OK in the meantime.Comment #75
longwaveThe updated code is entirely equivalent and while I'm not a fan of changing code just to work around a test or a tool, in this case it seems the most pragmatic thing to do.
Comment #76
andypostI don't wanna derail RTBC but 1.8.0 is out and it's required to parse PHP 8.2 attribute at least.
I filled #3293933: Upgrade phpstan/phpstan to 1.8.1 which looks a duplicate now
Comment #77
mondrake#73 is upgrading to 1.8.0, maybe IS needs a small update
Comment #78
andypostUpdated IS
Comment #79
andypostIt's a blocker for #3275851: [META] Fix PHP 8.2 dynamic property deprecations so raised to major
Comment #81
mondrakeRandom fail in #80?
Comment #82
alexpottNeeds a reroll now that the REQUEST_TIME issue has been resolved by #3112290: Replace REQUEST_TIME in procedural code
Comment #83
longwave#73 with the module and baseline changes removed following #3112290: Replace REQUEST_TIME in procedural code - this is composer.json/lock updates only now.
Comment #84
mondrakeBack to RTBC
Comment #85
andypost+1 RTBC, blocker for PHP 8.2
Comment #86
andypostNW for newer version https://github.com/mglaman/phpstan-drupal/releases/tag/1.1.21
Comment #87
andypostComment #88
andypostComment #89
longwaveRTBC assuming tests are green.
Comment #91
catchCommitted/pushed to 10.1.x and cherry-picked to 10.0.x, thanks!
Comment #92
andypostFollow-up filed #3293933: Upgrade phpstan/phpstan to 1.8.1
Comment #93
andypostShould we bump it again? at least for PHP 8.2 support