Problem/Motivation
If you forget that CacheableMetadata::merge() doesn't alter the object it's called on, you potentially mess up your caching and could cause data exposure.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3575492
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:
- 3575492-add-nodiscard-to-cache
changes, plain diff MR !14896
Comments
Comment #2
andypostwould be great to move here https://git.drupalcode.org/project/drupal/-/merge_requests/14887
Comment #4
andypostComment #5
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 #6
prudloff commentedI agree this would be useful. It is an easy mistake to make and it can cause serious cache bugs.
Comment #7
andypostas policy approved
Comment #8
smustgrave commentedLGTM
Comment #11
godotislateCommitted and pushed a7b77cb to main. and 08901b4 to 11.x. Thanks!
Comment #13
wim leersVery nice! 🎉
I predict that when the ecosystem starts requiring PHP 8.5, that this core commit will single-handedly trigger a bunch of contrib modules security releases 🔮