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.
Views default cache plugin checks $_GET items when building cache item id. It checks for several key in $_GET: exposed_info, page, sort and order
I have some views, where I use exposed sorts, filters and items_per_page. Items which I get in $_GET array are different from those beeing checked by views (sort_by, sort_order, items_per_page, date_filter in my case). Since Views ignores them I run into problems, since I get the same output for every exposed filters value.
I propose to change this I bit. I suggest that we check every value in $_GET, except q. Attached patch shows my idea.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1352362_cache_granulation_6.patch | 1.52 KB | slashrsm |
views_cache_granulation.patch | 1.6 KB | slashrsm | |
Comments
Comment #1
jrviorato CreditAttribution: jrviorato commentedI having the same problem, and I only use an exposed filter (a taxonomy term filter). One of the terms has no tagged elements, and i'm getting an empty page for every term that I select from the filter, even for those terms with a lot of tagged nodes.
It is in fact a cache problem, when I disable cache this problem disappears.
Comment #2
slashrsm CreditAttribution: slashrsm commentedHave you tried this patch?
Comment #3
jrviorato CreditAttribution: jrviorato commentedI just tried, and it does solves the issue.
Thank you
Comment #4
dawehnerI'm not sure whether it makes sense to add all parameters of $_GET because there maybe things which are too specific.
Comment #5
slashrsm CreditAttribution: slashrsm commentedThat was my thought also, but I was not sure how to decide which parameters are imprtant. As far as I noticed it is possible to get almost anything into $_GET, when using exposed filters. Specially if you use custom handlers.
Comment #6
slashrsm CreditAttribution: slashrsm commentedHow about this? Cound we also remove this code with this patch:
Comment #7
dawehnerRelying on $_GET here really makes no sense, right. Just opened another issue #1407044: Figure out the different between views->exposed_data and views->exposed_input because i had no clue whether exposed_input or exposed_data would be right here.
Do you have an idea about the other issue? ... i know i should know that :)
Comment #8
johnvThis is a duplicate of #1055616: Query arguments should be replaced before generating cache ID.
Can we continue over there? It contains the same patch for the same problem, and has a less techy problem description.
@slashrsm #6, getting rid of the foreach would be nice, but I did not succeed.