diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php index aecbc9f..59fc24f 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php @@ -31,7 +31,7 @@ public function process(ContainerBuilder $container) { $twig_extension_hash .= $class_name . filemtime($reflection->getFileName()); } - $container->setParameter('twig_extension_hash', $twig_extension_hash); + $container->setParameter('twig_extension_hash', hash('sha256', $twig_extension_hash)); } } diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 8d0e3ed..6c3a18c 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -51,13 +51,6 @@ class TwigEnvironment extends \Twig_Environment { protected $templateClasses; /** - * The Twig extension hash, which is used to invalidate Twig templates. - * - * @var string - */ - protected $twigExtensionHash; - - /** * Constructs a TwigEnvironment object and stores cache and storage * internally. * @@ -74,7 +67,7 @@ class TwigEnvironment extends \Twig_Environment { */ public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, \Twig_LoaderInterface $loader = NULL, $options = array()) { $this->cache_object = $cache; - $this->twigExtensionHash = $twig_extension_hash; + $this->templateCacheFilenamePrefix = $twig_extension_hash; // Ensure that twig.engine is loaded, given that it is needed to render a // template because functions like TwigExtension::escapeFilter() are called. @@ -132,11 +125,6 @@ public function getCacheFilename($name) { $class = substr($this->getTemplateClass($name), strlen($this->templateClassPrefix)); - // Just check the list of loaded extensions once. - if (!isset($this->templateCacheFilenamePrefix)) { - $this->templateCacheFilenamePrefix = hash('crc32b', $this->twigExtensionHash); - } - // The first part is what is invalidated. return $this->templateCacheFilenamePrefix . '_' . basename($name) . '_' . $class; }