bug #3675 Enable cache invalidation when auto_reload=true (GromNaN)

This PR was merged into the 2.x branch.

Discussion
----------

Enable cache invalidation when auto_reload=true

Related to https://github.com/symfony/symfony-docs/pull/16671

Enabling `auto_reload` is not effective when `opcache.validate_timestamps=0`.

Commits
-------

ef8ae9cb Enable bytecode invalidation with auto_reload
This commit is contained in:
Fabien Potencier
2022-04-05 18:27:00 +02:00
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -329,11 +329,11 @@ If you iterate over a set of files, you can pass the filename to the
is enforced during template rendering (as Twig needs the context for some
checks like allowed methods on objects).
Refreshing modified Templates when OPcache or APC is enabled
------------------------------------------------------------
Refreshing modified Templates when OPcache is enabled
-----------------------------------------------------
When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC
with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template
When using OPcache with ``opcache.validate_timestamps`` set to ``0``,
Twig cache enabled and auto reload disabled, clearing the template
cache won't update the cache.
To get around this, force Twig to invalidate the bytecode cache::
+1 -1
View File
@@ -264,7 +264,7 @@ class Environment
{
if (\is_string($cache)) {
$this->originalCache = $cache;
$this->cache = new FilesystemCache($cache);
$this->cache = new FilesystemCache($cache, $this->autoReload ? FilesystemCache::FORCE_BYTECODE_INVALIDATION : 0);
} elseif (false === $cache) {
$this->originalCache = $cache;
$this->cache = new NullCache();