PHP-Cache: does not work, always updates cached data

Created on 7 June 2021, almost 4 years ago
Updated 15 May 2023, almost 2 years ago

Problem/Motivation

Hi,
thank you for your work. However, using views_php 7.x-1.0 a problem occurs using the php-cache.

It didn't appear in 7.x-1.0-alpha3 and I've tested on PHP 7.3.27.

The problem:
Enter any php-code in the php-field ("Caching options") like "return true". You will see that the views-cache will be updated on each reload instead of "never" (what "return true" means).

Steps to reproduce

Create any view. Under advanced => cache select "PHP"
In Result cache code and Output cache code enter return true

Using devel you can see that for each reload the cached data is updated.

OR

in file views_php/plugins/views/views_php_plugin_cache.inc on line 74
add
drupal_set_message('in '.__FUNCTION__.' for '.$type . ' FRESH IS: '.var_export($fresh,1))

You will see that $fresh is always NULL. Which means: "refresh the cache".

Proposed resolution

A simple solution would be to add a "return" before each "eval" in the function cache_get($type).

Or maybe stick with the old $function = create_function('$view, $plugin, $cache', $this->options['php_cache_results'] . ';');

I don't know, which is better. But eval sounds more evil ;-)

Remaining tasks

fix php-cache

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

1.0

Component

Cache Plugin

Created by

🇩🇪Germany Bernhard Strehl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024