diff --git a/core/composer.json b/core/composer.json index 5befb3c..74fb485 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.22", + "twig/twig": "1.x-dev", "doctrine/common": "2.5.*", "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "~6.1", diff --git a/core/composer.lock b/core/composer.lock index 5563e7e..75480fc 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": "e917b58b5b2a847270d4bd49b0bcb22e", - "content-hash": "bbb9004b899df99873971591682b1e42", + "hash": "b8e9a41fa3316331ae6ce595a9eaec6e", + "content-hash": "0c460577ec3b4120d721bdb346a642d2", "packages": [ { "name": "doctrine/annotations", @@ -1779,16 +1779,16 @@ }, { "name": "twig/twig", - "version": "v1.22.1", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad" + "reference": "821464ad0137909bb38ad5dbf8a1f2230f33a9f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/b7fc2469fa009897871fb95b68237286fc54a5ad", - "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/821464ad0137909bb38ad5dbf8a1f2230f33a9f2", + "reference": "821464ad0137909bb38ad5dbf8a1f2230f33a9f2", "shasum": "" }, "require": { @@ -1836,7 +1836,7 @@ "keywords": [ "templating" ], - "time": "2015-09-15 06:50:16" + "time": "2015-09-21 07:07:22" }, { "name": "zendframework/zend-diactoros", @@ -3373,6 +3373,7 @@ "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 2deec5f..845f219 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -68,56 +68,6 @@ 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)); - } - - $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 258aa36..4f5e6b1 100644 --- a/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php +++ b/core/lib/Drupal/Core/Template/TwigPhpStorageCache.php @@ -81,13 +81,6 @@ public function generateKey($name, $className) { /** * {@inheritdoc} */ - public function has($key) { - return $this->storage()->exists($key); - } - - /** - * {@inheritdoc} - */ public function load($key) { $this->storage()->load($key); } diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 0655b5b..aba1783 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -3418,17 +3418,17 @@ }, { "name": "twig/twig", - "version": "v1.22.1", - "version_normalized": "1.22.1.0", + "version": "1.x-dev", + "version_normalized": "1.9999999.9999999.9999999-dev", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad" + "reference": "821464ad0137909bb38ad5dbf8a1f2230f33a9f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/b7fc2469fa009897871fb95b68237286fc54a5ad", - "reference": "b7fc2469fa009897871fb95b68237286fc54a5ad", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/821464ad0137909bb38ad5dbf8a1f2230f33a9f2", + "reference": "821464ad0137909bb38ad5dbf8a1f2230f33a9f2", "shasum": "" }, "require": { @@ -3438,7 +3438,7 @@ "symfony/debug": "~2.7", "symfony/phpunit-bridge": "~2.7" }, - "time": "2015-09-15 06:50:16", + "time": "2015-09-21 07:07:22", "type": "library", "extra": { "branch-alias": { diff --git a/core/vendor/twig/twig/CHANGELOG b/core/vendor/twig/twig/CHANGELOG index 7e33437..8163a13 100644 --- a/core/vendor/twig/twig/CHANGELOG +++ b/core/vendor/twig/twig/CHANGELOG @@ -1,3 +1,7 @@ +* 1.22.2 (2015-XX-XX) + + * fixed a race condition in template loading + * 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 50f5b45..258ab2f 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.1" +#define PHP_TWIG_VERSION "1.22.2-DEV" #include "php.h" diff --git a/core/vendor/twig/twig/lib/Twig/Cache/Filesystem.php b/core/vendor/twig/twig/lib/Twig/Cache/Filesystem.php index c33fa90..2e1c0a0 100644 --- a/core/vendor/twig/twig/lib/Twig/Cache/Filesystem.php +++ b/core/vendor/twig/twig/lib/Twig/Cache/Filesystem.php @@ -19,7 +19,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface const FORCE_BYTECODE_INVALIDATION = 1; private $directory; - private $invalidateBytecode; + private $options; /** * @param $directory string The root cache directory @@ -44,17 +44,9 @@ public function generateKey($name, $className) /** * {@inheritdoc} */ - public function has($key) - { - return is_file($key); - } - - /** - * {@inheritdoc} - */ public function load($key) { - require_once $key; + @include_once $key; } /** @@ -64,11 +56,8 @@ public function write($key, $content) { $dir = dirname($key); if (!is_dir($dir)) { - if (false === @mkdir($dir, 0777, true)) { - clearstatcache(false, $dir); - if (!is_dir($dir)) { - throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir)); - } + if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { + throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir)); } } elseif (!is_writable($dir)) { throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir)); @@ -98,6 +87,6 @@ public function write($key, $content) */ public function getTimestamp($key) { - return filemtime($key); + return (int) @filemtime($key); } } diff --git a/core/vendor/twig/twig/lib/Twig/Cache/Null.php b/core/vendor/twig/twig/lib/Twig/Cache/Null.php index 918e4ce..fde8c80 100644 --- a/core/vendor/twig/twig/lib/Twig/Cache/Null.php +++ b/core/vendor/twig/twig/lib/Twig/Cache/Null.php @@ -27,17 +27,8 @@ public function generateKey($name, $className) /** * {@inheritdoc} */ - public function has($key) - { - return false; - } - - /** - * {@inheritdoc} - */ public function write($key, $content) { - eval('?>'.$content); } /** @@ -52,7 +43,6 @@ public function load($key) */ public function getTimestamp($key) { - // never called as has() always returns false return 0; } } diff --git a/core/vendor/twig/twig/lib/Twig/CacheInterface.php b/core/vendor/twig/twig/lib/Twig/CacheInterface.php index fedd366..9b17e0f 100644 --- a/core/vendor/twig/twig/lib/Twig/CacheInterface.php +++ b/core/vendor/twig/twig/lib/Twig/CacheInterface.php @@ -31,15 +31,6 @@ public function generateKey($name, $className); /** - * Checks if the cache key exists. - * - * @param string $key The cache key - * - * @return bool true if the cache key exists, false otherwise - */ - public function has($key); - - /** * Writes the compiled template to cache. * * @param string $key The cache key diff --git a/core/vendor/twig/twig/lib/Twig/Environment.php b/core/vendor/twig/twig/lib/Twig/Environment.php index cd167bd..5d4c4cf 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.1'; + const VERSION = '1.22.2-DEV'; protected $charset; protected $loader; @@ -375,15 +375,20 @@ public function loadTemplate($name, $index = null) $key = $this->cache->generateKey($name, $cls); } - if (!$this->cache->has($key) || ($this->isAutoReload() && !$this->isTemplateFresh($name, $this->cache->getTimestamp($key)))) { + if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) { + $this->cache->load($key); + } + + if (!class_exists($cls, false)) { + $content = $this->compileSource($this->getLoader()->getSource($name), $name); if ($this->bcWriteCacheFile) { - $this->writeCacheFile($key, $this->compileSource($this->getLoader()->getSource($name), $name)); + $this->writeCacheFile($key, $content); } else { - $this->cache->write($key, $this->compileSource($this->getLoader()->getSource($name), $name)); + $this->cache->write($key, $content); } - } - $this->cache->load($key); + eval('?>'.$content); + } } if (!$this->runtimeInitialized) { diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Core.php b/core/vendor/twig/twig/lib/Twig/Extension/Core.php index 3716f02..f9ec2a4 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Core.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Core.php @@ -885,6 +885,9 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n // The '_default' filter is used internally to avoid using the ternary operator // which costs a lot for big contexts (before PHP 5.4). So, on average, // a function call is cheaper. +/** + * @internal + */ function _twig_default_filter($value, $default = '') { if (twig_test_empty($value)) { @@ -982,7 +985,9 @@ function twig_sort_filter($array) return $array; } -/* used internally */ +/** + * @internal + */ function twig_in_filter($value, $compare) { if (is_array($compare)) { @@ -1150,7 +1155,9 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', } } -/* used internally */ +/** + * @internal + */ function twig_escape_filter_is_safe(Twig_Node $filterArgs) { foreach ($filterArgs as $arg) { @@ -1396,7 +1403,9 @@ function twig_capitalize_string_filter(Twig_Environment $env, $string) } } -/* used internally */ +/** + * @internal + */ function twig_ensure_traversable($seq) { if ($seq instanceof Traversable || is_array($seq)) { diff --git a/core/vendor/twig/twig/lib/Twig/Extension/Staging.php b/core/vendor/twig/twig/lib/Twig/Extension/Staging.php index 8ab0f45..583e6a9 100644 --- a/core/vendor/twig/twig/lib/Twig/Extension/Staging.php +++ b/core/vendor/twig/twig/lib/Twig/Extension/Staging.php @@ -15,6 +15,8 @@ * This class is used by Twig_Environment as a staging area and must not be used directly. * * @author Fabien Potencier + * + * @internal */ class Twig_Extension_Staging extends Twig_Extension { diff --git a/core/vendor/twig/twig/lib/Twig/Loader/String.php b/core/vendor/twig/twig/lib/Twig/Loader/String.php index 9bfd856..00f507a 100644 --- a/core/vendor/twig/twig/lib/Twig/Loader/String.php +++ b/core/vendor/twig/twig/lib/Twig/Loader/String.php @@ -23,6 +23,8 @@ * * @deprecated since 1.18.1 (to be removed in 2.0) * + * @internal + * * @author Fabien Potencier */ class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface diff --git a/core/vendor/twig/twig/lib/Twig/Template.php b/core/vendor/twig/twig/lib/Twig/Template.php index 36d4162..a816022 100644 --- a/core/vendor/twig/twig/lib/Twig/Template.php +++ b/core/vendor/twig/twig/lib/Twig/Template.php @@ -61,6 +61,8 @@ public function getEnvironment() * @param array $context * * @return Twig_TemplateInterface|false The parent template or false if there is no parent + * + * @internal */ public function getParent(array $context) { @@ -111,6 +113,8 @@ public function isTraitable() * @param string $name The block name to display from the parent * @param array $context The context * @param array $blocks The current set of blocks + * + * @internal */ public function displayParentBlock($name, array $context, array $blocks = array()) { @@ -135,6 +139,8 @@ public function displayParentBlock($name, array $context, array $blocks = array( * @param array $context The context * @param array $blocks The current set of blocks * @param bool $useBlocks Whether to use the current set of blocks + * + * @internal */ public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true) { @@ -191,6 +197,8 @@ public function displayBlock($name, array $context, array $blocks = array(), $us * @param array $blocks The current set of blocks * * @return string The rendered block + * + * @internal */ public function renderParentBlock($name, array $context, array $blocks = array()) { @@ -212,6 +220,8 @@ public function renderParentBlock($name, array $context, array $blocks = array() * @param bool $useBlocks Whether to use the current set of blocks * * @return string The rendered block + * + * @internal */ public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true) { @@ -237,6 +247,8 @@ public function renderBlock($name, array $context, array $blocks = array(), $use * @param string $name The block name * * @return bool true if the block exists, false otherwise + * + * @internal */ public function hasBlock($name) { @@ -252,6 +264,8 @@ public function hasBlock($name) * @return array An array of block names * * @see hasBlock + * + * @internal */ public function getBlockNames() { @@ -298,6 +312,8 @@ protected function loadTemplate($template, $templateName = null, $line = null, $ * @return array An array of blocks * * @see hasBlock + * + * @internal */ public function getBlocks() { @@ -407,6 +423,8 @@ protected function displayWithErrorHandling(array $context, array $blocks = arra * @return mixed The content of the context variable * * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode + * + * @internal */ final protected function getContext($context, $item, $ignoreStrictCheck = false) {