Filter plugin cache disable is not working

Created on 8 June 2017, about 7 years ago
Updated 30 November 2023, 7 months ago

Hi,

On my client website, I've enabled PHP β†’ module and I've noticed that the results are cached, and the cache => FALSE option on the php\src\Plugin\Filter\Php.php is ignored:

/**
 * Provides PHP code filter. Use with care.
 *
 * @Filter(
 *   id = "php_code",
 *   module = "php",
 *   title = @Translation("PHP evaluator"),
 *   description = @Translation("Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!"),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
<strong> *   cache = FALSE</strong>
 * )
 */

How to reproduce:
1. Enable PHP module and Create block
2. Text format: PHP
3. Insert code <?php print time(); ?>
4. Save block and assign it to any region
5. Open the page and check the result
6. Refresh the page or open another page - the result will be the same

The very strange is that fact that on my local fresh environment I don't have such problems and results are NOT cached.
Is this mean that there are some other drupal settings which control the block cache?

Thanks.

πŸ› Bug report
Status

Closed: works as designed

Version

8.5 ⚰️

Component
FilterΒ  β†’

Last updated about 6 hours ago

No maintainer
Created by

πŸ‡²πŸ‡©Moldova NikaDevs

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.

  • πŸ‡²πŸ‡©Moldova gzveri

    Comment in #10 helped.
    This worked for me in Drupal9 , I needed the replaced text not being cached.

        $result = new FilterProcessResult($new_text);
        $result->setCacheMaxAge(0); // don't cache.
        return $result;
    
Production build 0.69.0 2024