- Issue created by @alexpott
- πΊπΈUnited States nicxvan
Just noting @larowlan wanted them private originally, just curious if we should re evaluate here or if self is enough.
- π¬π§United Kingdom alexpott πͺπΊπ
Imo leave them as private - I've added a PHPStan rule that covers this situation. It's just a mistake to access private constants with static.
- π¬π§United Kingdom longwave UK
As the methods that use the constants are protected shouldn't the constants also be protected? Or are we saying you shouldn't actually be overriding those methods?
- πΊπΈUnited States nicxvan
https://git.drupalcode.org/project/drupal/-/merge_requests/11796#note_50...
This is where it was discussed.
- πΊπΈUnited States nicxvan
That failure might be real, I have rerun it 3 or 4 times.
- π¬π§United Kingdom alexpott πͺπΊπ
The failure has nothing to do with this change - it is one of the frontend changes from today.
- π¬π§United Kingdom alexpott πͺπΊπ
π Fix AssetAggregationAcrossPagesTest Active is the fix for the testing issue on 11.x
- π¬π§United Kingdom catch
Looks like the idea behind making them private was because they might be temporary and be removed later, I think the MR here is fine for a quick fix, we can re-evaluate the constants themselves later.
- πΊπΈUnited States xjm
I saw remarks elsewhere that some other recent commit might have added instability to the functional JS tests, so I queued it again.
- πΊπΈUnited States nicxvan
The one that Alex posted is the test that was failing, this has not been rebased so it won't pass tests.
- πΊπΈUnited States nicxvan
Also do we have a link to the other constants where they got added? I am only familiar with the registry ones but there are other constants in the mr.
- πΊπΈUnited States xjm
The failure is to do with asset aggregation in Umami:
Time: 03:16.817, Memory: 10.00 MB 452 453 Asset Aggregation Across Pages (Drupal\Tests\demo_umami\FunctionalJavascript\AssetAggregationAcrossPages) 454 β Front and recipes pages 455 β Front and recipes pages authenticated 456 β Front and recipes pages editor 457 β 458 β Asserting ScriptBytes 335003 is greater or equal to 335137 and is smaller or equal to 336137 459 β Failed asserting that 335003 ( is equal to 335137 or is greater than 335137 ) and ( is equal to 336137 or is less than 336137 ). 460 466 FAILURES! 467 Tests: 3, Assertions: 29, Failures: 1, PHPUnit Deprecations: 8.
So if that was the exact fail as before or after, we might worry. But I just checked and requeued the dailies, and they're also full of functional JS fails.
- πΊπΈUnited States xjm
I think this is fine as a hotfix; we can file followups if we want to discuss further or change other constants.
Saving issue credits; hopefully the rebased pipeline will be done by then.
- πΊπΈUnited States xjm
For some reason now it's not triggering the later stages of the pipeline.
- πΊπΈUnited States nicxvan
I see that too, I am also logged in. Might be worth asking in infra.
- πΊπΈUnited States nicxvan
I created a new branch from this one too trigger a fresh pipeline to see if that works.
Unfortunately I had typos in the title lol.
- πΊπΈUnited States xjm
I did leave a message about it in
#gitlab
, yeah.Committed the results from the helpful
tesr-pupeline
branch π€£ to 11.x.It doesn't cherry-pick cleanly to 11.2.x in
core/lib/Drupal/Core/Theme/Registry.php
, but we should make a separate version without the PHPStan rule addition anyway. - π¬π§United Kingdom catch
Pipeline weirdness might be fixed by giving yourself push access to the branch, I think I've had the same thing happen.
- π¬π§United Kingdom alexpott πͺπΊπ
alexpott β changed the visibility of the branch 3531412-tesr-pupeline to hidden.
- π¬π§United Kingdom alexpott πͺπΊπ
alexpott β changed the visibility of the branch 3531412-new-constants-in to hidden.
- Merge request !12435Issue #3531412 by alexpott, xjm, nicxvan, longwave, catch: New constants in... β (Open) created by alexpott
- π¬π§United Kingdom alexpott πͺπΊπ
I've cherry-picked the 11.x commit to the 11.2.x and resolved conflicts and backed out the PHPStan change.
I ran
vendor/bin/phpstan analyse -c core/phpstan.neon.dist core/lib/Drupal/Core/Theme/Registry.php --level=2
and confirmed that the constant issue is fixed on 11.2.x too. - πΊπΈUnited States xjm
Looks like it was these lines that were added in 11.x and prevented the cherry-pick, so it's a good thing we added the rule to HEAD at least:
- $cache[static::GLOBAL_PREPROCESS] = $this->collectModulePreprocess($cache, 'preprocess'); + $cache[self::GLOBAL_PREPROCESS] = $this->collectModulePreprocess($cache, 'preprocess');
We should possibly backport the rule itself to 10.6.x as well.
- π¬π§United Kingdom alexpott πͺπΊπ
FWIW now we have the PHPStan rule in place, I think private constants are fine. In this case the constant is for an implementation detail of the code in \Drupal\Core\Theme\Registry - using a private constant means that anything that extends it should not rely on this implementation detail - which feels like fine architectural decision to me. I think we should only open a follow-up if we have an architectural reason to allow classes that extend \Drupal\Core\Theme\Registry access to the constant. For Twig UI this is not necessary at all. Somewhat sadly the 8.x-3.x version of Bootstrap hit this problem a couple of weeks ago but fixed it incorrectly in the Bootstrap theme rather than opening a core issue - see π Undefined constant Drupal\bootstrap\Plugin\Alter\ThemeRegistry::PREPROCESS_INVOKES in Drupal\Core\Theme\Registry->postProcessExtension() Active - I will open an issue against Bootstrap to revert that change once we have released the hotfix.
- π¬π§United Kingdom alexpott πͺπΊπ
Ah the bootstrap fix is yet to be merged. Another reason to get this fix released ASAP as we now have 2 confirmed cases in contrib and Bootstrap 8.x-3.x has about 50,000 users β .
- πΊπΈUnited States nicxvan
My two cents is if we are worried about people resulting in it we should have just used the array value.
If we want them to be constants for consistency then they should be marked internal.
Just because we don't know why someone would want to use it doesn't mean we should preclude it.
This issue is an example of why, if they had not been private I don't think this issue would have existed in the first place right?
- π¬π§United Kingdom alexpott πͺπΊπ
@nicxvan if they were not private yeah no issue... but the issue is not caused by the code in modules trying to use the constant. It is caused the late static binding... see https://3v4l.org/MDU2P
I think we now have static analysis checking then it is fine to have private constants but before I'd agree that it is very easy to make a mistake.