diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php index 35dd690..caade2d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TwigExtensionPass.php @@ -11,9 +11,10 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; /** - * Adds twig_extension_hash parameter to the container. + * Adds the twig_extension_hash parameter to the container. * - * A hash of all extensions for Twig template invalidation. + * twig_extension_hash is a hash of all extension mtimes for Twig template + * invalidation. */ class TwigExtensionPass implements CompilerPassInterface { @@ -23,7 +24,10 @@ class TwigExtensionPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $twig_extension_hash = ''; foreach (array_keys($container->findTaggedServiceIds('twig.extension')) as $service_id) { - $twig_extension_hash .= $container->getDefinition($service_id)->getClass(); + $reflecton = new \ReflectionClass($container->getDefinition($service_id)->getClass()); + // We use mtime to invalidate both on new extensions and changes of + // existing ones. + $twig_extension_hash .= filemtime($reflecton->getFileName()); } $container->setParameter('twig_extension_hash', $twig_extension_hash);