Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While working on #2596649: Exposed form does not save state when it is placed in a block I found out that views exposed filters provide broad cache contexts (they mark the URL as context). Their real context however is just specific query arguments on the URL, so they should provide url.query_args:*** as their cache context.
Attached patch fixes this, but will probably break tests.
Comment | File | Size | Author |
---|---|---|---|
more-specific-exposed-filter-cache-contexts.patch | 862 bytes | legolasbo | |
Comments
Comment #2
legolasboHmm, seems like the cache contexts for these filters don't have test coverage.
Comment #3
dawehnerI'm quite sure that this issue is a duplicate of some other issue, but I can't find the other issue at the moment. IMHO when this issue has a test, we could also just get this issue!
Comment #4
alexej_d CreditAttribution: alexej_d commentedProbably it's the same as here Exposed form in a block rendered on another page than the view is displayed breaks the "Remember the last selection" option.
Comment #5
legolasbo@alexej_d,
I think the issue you mentioned is actually related to #2596649: Exposed form does not save state when it is placed in a block since the exposed form block doesn't currently provide any cache contexts. This issue is about the fact that the cacheContext exposed filters in general is currently the entire URL, while it should be specific URL arguments.
Comment #6
Wim LeersI think the issue @dawehner is thinking of is #2503185: Specify a more specific cache context in FilterPluginBase.
Comment #7
legolasboThanks Wim,
closing this as a duplicate of #2503185: Specify a more specific cache context in FilterPluginBase