- 🇩🇪Germany Schoenef Unna
Please open a new issue for the 2.0 version, if this is still an issue.
I would like to add time-based caching to my Views XML Backend views. I noticed when enabling it, it always displays the same output for every use-case. It doesn't take any arguments into account. This is not the case with views using the default backend (SQL).
I dug into the code responsible for time-based views caching, and noticed the following bit of code in the get_cache_key() function (views_plugin_cache.inc):
if (empty($key_data['build_info'])) {
$build_info = $this->view->build_info;
foreach (array('query','count_query') as $index) {
// If the default query back-end is used generate SQL query strings from
// the query objects.
if ($build_info[$index] instanceof SelectQueryInterface) {
$query = clone $build_info[$index];
$query->preExecute();
$key_data['build_info'][$index] = array(
'sql' => (string) $query,
'arguments' => $query->getArguments(),
);
}
}
}
// ...
$key = md5(serialize($key_data));
Essentially, only queries which are instances of SelectQueryInterface influence how to the key is generated. Since this is not the case, cache keys are the same for all Views XML Backend results.
Attached patch is a solution to this problem. I couldn't find another way than creating a new cache plugin, albeit a very tiny one and derived from the default views_plugin_cache_time plugin. Seems to work like a charm on my installation.
Closed: won't fix
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Please open a new issue for the 2.0 version, if this is still an issue.