[HttpKernel] Adjust priority of CacheAttributeListener
to ensure Vary header is not skipped
#61368
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates the priority of the
KernelEvents::RESPONSE
event from -10 to 10 in theCacheAttributeListener
.Reason
Previously, the
CacheAttributeListener
was executed after theResponseListener
. When theset_locale_from_accept_language
option is enabled inframework.yaml
, theResponseListener
sets a Vary header on the response. BecauseCacheAttributeListener
checks if a Vary header already exists before modifying it, its logic was being bypassed if it ran after theResponseListener
.Fix
By increasing the event priority, we ensure the
CacheAttributeListener
runs before theResponseListener
, allowing it to correctly evaluate and modify the Vary header when necessary.References
Note
I'm not sure if changing the priority of this event in this listener could have other side effects.