Skip to content

[HttpKernel] Refine Vary header check to skip special handling of 'Accept-Language' when it's the only entry and '_vary_by_language' is true in CacheAttributeListener #61368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6.4
Choose a base branch
from

Conversation

santysisi
Copy link
Contributor

@santysisi santysisi commented Aug 9, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #61229
License MIT

Summary

Refine Vary header check to skip special handling of 'Accept-Language' when it's the only entry and '_vary_by_language' is true in CacheAttributeListener

Reason

Previously, the CacheAttributeListener was executed after the ResponseListener. When the set_locale_from_accept_language option is enabled in framework.yaml, the ResponseListener sets a Vary header on the response. Because CacheAttributeListener checks if a Vary header already exists before modifying it, its logic was being bypassed if it ran after the ResponseListener.

References

@carsonbot

This comment has been minimized.

@carsonbot carsonbot added this to the 7.4 milestone Aug 9, 2025
@santysisi santysisi changed the base branch from 7.4 to 6.4 August 9, 2025 00:47
@santysisi santysisi force-pushed the fix/cache-listener-priority branch from 9eec426 to 04f4315 Compare August 9, 2025 00:48
@santysisi
Copy link
Contributor Author

If we want to avoid changing the priority, we can add a condition to check whether the request has the _vary_by_language attribute set to true, and the response's Vary header contains only Accept-Language.

@nicolas-grekas
Copy link
Member

check whether the request has the _vary_by_language

let's do this, so that this won't interfere with app's listeners

@santysisi santysisi force-pushed the fix/cache-listener-priority branch 2 times, most recently from 8240e2d to 8085b7e Compare August 20, 2025 02:18
@santysisi santysisi changed the title [HttpKernel] Adjust priority of CacheAttributeListener to ensure Vary header is not skipped [HttpKernel] Refine Vary header check to ignore 'Accept-Language' when handled by request in CacheAttributeListener Aug 20, 2025
@santysisi santysisi force-pushed the fix/cache-listener-priority branch from 8085b7e to 4a186a5 Compare August 20, 2025 02:20
@santysisi santysisi changed the title [HttpKernel] Refine Vary header check to ignore 'Accept-Language' when handled by request in CacheAttributeListener [HttpKernel] Refine Vary header check to skip special handling of 'Accept-Language' when it's the only entry and '_vary_by_language' is true in CacheAttributeListener Aug 20, 2025
@santysisi santysisi force-pushed the fix/cache-listener-priority branch from 4a186a5 to 85c3d45 Compare August 20, 2025 02:27
@santysisi
Copy link
Contributor Author

santysisi commented Aug 20, 2025

status: needs work

There is a problem, i will try to resolve that problem tomorrow

…cept-Language' when it's the only entry and '_vary_by_language' is `true`

 in `CacheAttributeListener`
@santysisi santysisi force-pushed the fix/cache-listener-priority branch from 85c3d45 to 34293e7 Compare August 22, 2025 22:03
@santysisi
Copy link
Contributor Author

status: needs review

The problem was resolved by sending the 'Accept-Language' header at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CacheAttributeListener overrides custom Vary headers when set_locale_from_accept_language is enabled
3 participants