diff --git a/core/composer.json b/core/composer.json index 74fb485..5befb3c 100644 --- a/core/composer.json +++ b/core/composer.json @@ -17,7 +17,7 @@ "symfony/validator": "2.7.*", "symfony/process": "2.7.*", "symfony/yaml": "2.7.*", - "twig/twig": "1.x-dev", + "twig/twig": "~1.22", "doctrine/common": "2.5.*", "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "~6.1", diff --git a/core/composer.lock b/core/composer.lock index c52e010..5563e7e 100644 --- a/core/composer.lock +++ b/core/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b8e9a41fa3316331ae6ce595a9eaec6e", - "content-hash": "0c460577ec3b4120d721bdb346a642d2", + "hash": "e917b58b5b2a847270d4bd49b0bcb22e", + "content-hash": "bbb9004b899df99873971591682b1e42", "packages": [ { "name": "doctrine/annotations", @@ -1779,16 +1779,16 @@ }, { "name": "twig/twig", - "version": "1.x-dev", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9fde02fe552256722466c9985520b6f50c9c759b" + "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9fde02fe552256722466c9985520b6f50c9c759b", - "reference": "9fde02fe552256722466c9985520b6f50c9c759b", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b7fc2469fa009897871fb95b68237286fc54a5ad", + "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad", "shasum": "" }, "require": { @@ -1836,7 +1836,7 @@ "keywords": [ "templating" ], - "time": "2015-09-16 08:32:19" + "time": "2015-09-15 06:50:16" }, { "name": "zendframework/zend-diactoros", @@ -3373,7 +3373,6 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "twig/twig": 20, "behat/mink-goutte-driver": 20 }, "prefer-stable": true, diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 845f219..64399bf 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -68,6 +68,59 @@ public function __construct($root, CacheBackendInterface $cache, $twig_extension } /** + * Implements Twig_Environment::loadTemplate(). + * + * We need to overwrite this function to integrate with drupal_php_storage(). + * + * This is a straight copy from loadTemplate() changed to use + * drupal_php_storage(). + * + * @param string $name + * The template name or the string which should be rendered as template. + * @param int $index + * The index if it is an embedded template. + * + * @return \Twig_TemplateInterface + * A template instance representing the given template name. + * + * @throws \Twig_Error_Loader + * When the template cannot be found. + * @throws \Twig_Error_Syntax + * When an error occurred during compilation. + */ + public function loadTemplate($name, $index = NULL) { + $cls = $this->getTemplateClass($name, $index); + + if (isset($this->loadedTemplates[$cls])) { + return $this->loadedTemplates[$cls]; + } + + if (!class_exists($cls, FALSE)) { + $key = $this->cache->generateKey($name, $cls); + + if (!$this->cache->has($key) || ($this->isAutoReload() && !$this->isTemplateFresh($name, $this->cache->getTimestamp($key)))) { + $this->cache->write($key, $this->compileSource($this->getLoader()->getSource($name), $name)); + } + + if (!$this->cache->load($key)) { + $this->cache->write($key, $this->compileSource($this->getLoader()->getSource($name), $name)); + $this->cache->load($key); + } + + if (!class_exists($cls, FALSE)) { + $compiled_source = $this->compileSource($this->loader->getSource($name), $name); + eval('?' . '>' . $compiled_source); + } + } + + if (!$this->runtimeInitialized) { + $this->initRuntime(); + } + + return $this->loadedTemplates[$cls] = new $cls($this); + } + + /** * Gets the template class associated with the given string. * * @param string $name diff --git a/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php b/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php index 1f5e77c..b660e72 100644 --- a/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php +++ b/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php @@ -94,15 +94,7 @@ public function has($key) { * {@inheritdoc} */ public function load($key) { - // if (!$this->storage()->load($key)) { - if (TRUE) { - // eval() the stored template since we were not able to load it from - // storage. - // - // This only works when the PhpStorage cache is cold, it does not help us - // if has() returns TRUE because then write() is not called. :( - eval('?>' . $this->templateSourceCache[$key]); - } + return $this->storage()->load($key); } /** diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 3ca2ada..0655b5b 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -3418,17 +3418,17 @@ }, { "name": "twig/twig", - "version": "1.x-dev", - "version_normalized": "1.9999999.9999999.9999999-dev", + "version": "v1.22.1", + "version_normalized": "1.22.1.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9fde02fe552256722466c9985520b6f50c9c759b" + "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9fde02fe552256722466c9985520b6f50c9c759b", - "reference": "9fde02fe552256722466c9985520b6f50c9c759b", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/b7fc2469fa009897871fb95b68237286fc54a5ad", + "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad", "shasum": "" }, "require": { @@ -3438,7 +3438,7 @@ "symfony/debug": "~2.7", "symfony/phpunit-bridge": "~2.7" }, - "time": "2015-09-16 08:32:19", + "time": "2015-09-15 06:50:16", "type": "library", "extra": { "branch-alias": { diff --git a/core/vendor/twig/twig/CHANGELOG b/core/vendor/twig/twig/CHANGELOG index 3966a3e..7e33437 100644 --- a/core/vendor/twig/twig/CHANGELOG +++ b/core/vendor/twig/twig/CHANGELOG @@ -1,7 +1,3 @@ -* 1.22.2 (2015-XX-XX) - - * fixed Twig_Cache_Null logic - * 1.22.1 (2015-09-15) * fixed regression in template_from_string diff --git a/core/vendor/twig/twig/ext/twig/php_twig.h b/core/vendor/twig/twig/ext/twig/php_twig.h index 258ab2f..50f5b45 100644 --- a/core/vendor/twig/twig/ext/twig/php_twig.h +++ b/core/vendor/twig/twig/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.22.2-DEV" +#define PHP_TWIG_VERSION "1.22.1" #include "php.h" diff --git a/core/vendor/twig/twig/lib/Twig/Cache/Null.php b/core/vendor/twig/twig/lib/Twig/Cache/Null.php index 6a9a29b..918e4ce 100644 --- a/core/vendor/twig/twig/lib/Twig/Cache/Null.php +++ b/core/vendor/twig/twig/lib/Twig/Cache/Null.php @@ -16,14 +16,12 @@ */ class Twig_Cache_Null implements Twig_CacheInterface { - private $buffer = array(); - /** * {@inheritdoc} */ public function generateKey($name, $className) { - return $className; + return ''; } /** @@ -39,7 +37,7 @@ public function has($key) */ public function write($key, $content) { - $this->buffer[$key] = $content; + eval('?>'.$content); } /** @@ -47,9 +45,6 @@ public function write($key, $content) */ public function load($key) { - eval('?>'.$this->buffer[$key]); - - unset($this->buffer[$key]); } /** diff --git a/core/vendor/twig/twig/lib/Twig/Environment.php b/core/vendor/twig/twig/lib/Twig/Environment.php index 565ec47..cd167bd 100644 --- a/core/vendor/twig/twig/lib/Twig/Environment.php +++ b/core/vendor/twig/twig/lib/Twig/Environment.php @@ -16,7 +16,7 @@ */ class Twig_Environment { - const VERSION = '1.22.2-DEV'; + const VERSION = '1.22.1'; protected $charset; protected $loader;