Download & Extend

PHP field in view header is not cached correctly when view has no result

Project:Views PHP
Version:7.x-1.x-dev
Component:Cache Plugin
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I'm using a PHP field in view header to display a message of the kind "There's no result for "+ user friendly display of a contextual filter. Of course I checked the "Display even if view has no result" box for this field, which is in this case necessary to get what I want to (with a "if (empty($results))" test).

I have set the "Time based" cache with Query results = 5 mn / Rendered output = 5 mn.

Everything works fine except when the view has no result : in this case, the PHP field is cached without considering the contextual filters : It's well cached, but when I change the contextual filter for another value that will also display no result, exactly the same result is displayed (whereas when the view has results the cache is working well : it depends on the contextual filter).

I joined a simple view export to help reproduce this bug ; it has one contextual filter "month" filtering on date creation of nodes. I have few nodes only on certain months. To see what happens go to urls like php-cache-test/06 or php-cache-test/11 for me these two ones have no content, and I get the header "Contextual filter = "06" - 10:28:22" for these two months : the cache does not consider the contextual filter, and seems global.

The code of the PHP field in this test view is:
<h4>Contextual filter = "<?php print $view->args[0];?>" - <?php print date('H:i:s', time());?></h4>

I had to deactivate the "Rendered output" cache part to get it work as expected ; it forces the rendering each time.

Hope someone could solve this, thanks !

AttachmentSize
php_cache_test.txt4.73 KB

Comments

#1

I have the same problem, really annoying..
If I do an arg(1) for example it doesn't give me the argument of the current url..