diff --git a/CHANGELOG b/CHANGELOG index c7fc76487..ec589ec10 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.22.3 (2015-XX-XX) - * n/a + * changed template cache names to take into account the Twig C extension * 1.22.2 (2015-09-22) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 00aa8789a..2b3676df9 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -291,6 +291,12 @@ class Twig_Environment /** * Gets the template class associated with the given string. * + * The generated template class is based on the following parameters: + * + * * The cache key for the given template; + * * The currently enabled extensions; + * * Whether the Twig C extension is available or not. + * * @param string $name The name for which to calculate the template class name * @param int $index The index if it is an embedded template * @@ -300,6 +306,10 @@ class Twig_Environment { $key = $this->getLoader()->getCacheKey($name).'__'.implode('__', array_keys($this->extensions)); + if (function_exists('twig_template_get_attributes')) { + $key .= '__cext'; + } + return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index); }