Fixed
Project:
Drupal core
Version:
10.6.x-dev
Component:
base system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Dec 2025 at 08:57 UTC
Updated:
25 Mar 2026 at 16:04 UTC
Jump to comment: Most recent
Comments
Comment #2
andypostComment #5
andypostComment #6
andypostComment #7
smustgrave commentedSorry no harm in being review but don't want to accidentally get reviewed. #3575572: Add [#NoDiscard] to Utility classes is determining if this is worth it.
Comment #8
andypostHere the reason is clear - even exposing a bug
Comment #9
longwave+1 to fixing this given that it's found a genuine bug. Technically this is a security issue but it appears to be such an edge case - the user has access to view all revisions, and is viewing a non-default revision, and doesn't have access to view the original revision - that I think this is better just to fix here.
Comment #10
longwaveFWIW I think this should be backported to 10.6 as well, bumping priority too.
Comment #11
benjifisher+1 for RTBC.
If we backport this issue to 11.3 and 10.6, then we should not add
#[NoDiscard]since it can generate errors, flooding logs and causing automated tests to fail.Comment #14
godotislateCommitted a94c396 and pushed to main and
committed bcfde83 and pushed to 11.x.
Re: #11: we have symfony/polyfill-php85 on 11.3.x, which is documented to support NoDiscard, but I have seen PHPStan complain on array_all or array_any on a build, even with the polyfill. I'll see what the 11.x 8.3 pipelines look like before pushing.
This will need a backport for 10.6.x with NoDiscard removed, though.
Comment #15
benjifisherIn Comment #11, I should have said "warnings", not "errors". Warnings are enough to flood logs and to break automated tests and related CI.
@godotislate, I do not see how having a polyfill affects these reasons not to add
#[NoDiscard]in a patch release.Comment #16
godotislateI assume you mean the warnings about the attribute not being defined in PHP < 8.5?
ETA. I'm fine with an MR to remove the attributes for 11.3.x as well.
Comment #17
longwaveI think @benjifisher means the warnings are a behaviour change for anyone who is currently accessing these APIs incorrectly, it might start triggering messages in their logs or CI etc. It is okay to start warning these users in the next minor but we should not do it in a patch release.
Comment #18
benjifisher@godotislate:
From https://www.php.net/NoDiscard:
Testing with PHP 8.5.2:
then
Comment #19
godotislate@benjifisher: heard.
I thought you were talking about 11.3.x or 10.6.x CI builds running on PHP 8.3 or 8.4 and failing because of PHPStan flagging NoDiscard as an undefined attribute. It didn't occur to me that hose builds could be running on PHP 8.5.
Comment #21
catchComment #22
benjifisher@catch: @goditislate already committed the fix to the
mainand11.xbranches, so I am updating the branch to11.3.x.I prepared MR !15196 for the 11.3.x branch. As I said in Comment #11, we should not back-port the
#[NoDiscard]annotation to patch releases. The commit should cherry-pick cleanly to the other supported branches.I needed some help to get the tests to run, but now they are all green, so back to NR.
Comment #27
godotislateThank you @benjifisher for the port. It also applied clean to 10.6.x.
Committed 5c02b60 and pushed to 11.3.x and committed 4b3b0b4 and pushed to 10.6.x. Thanks!