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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jrviorato’s picture

I 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.

slashrsm’s picture

Have you tried this patch?

jrviorato’s picture

I just tried, and it does solves the issue.

Thank you

dawehner’s picture

I'm not sure whether it makes sense to add all parameters of $_GET because there maybe things which are too specific.

slashrsm’s picture

That 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.

slashrsm’s picture

How about this? Cound we also remove this code with this patch:

      foreach (array('exposed_info', 'page', 'sort', 'order') as $key) {
        if (isset($_GET[$key])) {
          $key_data[$key] = $_GET[$key];
        }
      }
dawehner’s picture

Relying 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 :)

johnv’s picture

Status: Needs review » Closed (duplicate)

This 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.