diff --git a/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php b/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php index b660e72..85abe24 100644 --- a/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php +++ b/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php @@ -12,6 +12,13 @@ /** * Provides an alternate cache storage for Twig using PhpStorage. + * + * This class is designed to work on setups with multiple webheads using a local + * filesystem for the twig cache. When generating the cache key, a hash value + * depending on the enabled extensions is included. This prevents stale + * templates from being reused when twig extensions are enabled or disabled. + * + * @see \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass */ class TwigPhpStorageCache implements \Twig_CacheInterface { @@ -37,13 +44,6 @@ class TwigPhpStorageCache implements \Twig_CacheInterface { protected $templateCacheFilenamePrefix; /** - * Template source cache for when the template cannot be loaded from storage. - * - * @var array - */ - protected $templateSourceCache = []; - - /** * Store cache backend and other information internally. * * @param \Drupal\Core\Cache\CacheBackendInterface $cache @@ -72,11 +72,6 @@ protected function storage() { * {@inheritdoc} */ public function generateKey($name, $className) { - // We override the cache filename in order to avoid issues with not using - // shared filesystems. The Twig templates for example rely on available Twig - // extensions, so we use the Twig extension hash which varies by extensions - // and their mtime. - // @see \Drupal\Core\DependencyInjection\Compiler\TwigExtensionPass $hash = hash('sha256', $className); // The first part is what is invalidated. @@ -94,7 +89,7 @@ public function has($key) { * {@inheritdoc} */ public function load($key) { - return $this->storage()->load($key); + $this->storage()->load($key); } /** @@ -102,8 +97,6 @@ public function load($key) { */ public function write($key, $content) { $this->storage()->save($key, $content); - // Store the compiled template in case loading from PhpStorage fails. - $this->templateSourceCache[$key] = $content; // Save the last mtime. $cid = 'twig:' . $key; $this->cache->set($cid, REQUEST_TIME);