diff --git a/composer.lock b/composer.lock index ef5c03a5fe3..f14977eb0d8 100644 --- a/composer.lock +++ b/composer.lock @@ -2021,7 +2021,7 @@ }, { "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" + "email": "backendtea@gmail.com" } ], "description": "Symfony polyfill for ctype functions", @@ -2691,31 +2691,31 @@ }, { "name": "twig/twig", - "version": "v1.35.4", + "version": "v1.38.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "7e081e98378a1e78c29cc9eba4aefa5d78a05d2a" + "reference": "874adbd9222f928f6998732b25b01b41dff15b0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/7e081e98378a1e78c29cc9eba4aefa5d78a05d2a", - "reference": "7e081e98378a1e78c29cc9eba4aefa5d78a05d2a", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/874adbd9222f928f6998732b25b01b41dff15b0c", + "reference": "874adbd9222f928f6998732b25b01b41dff15b0c", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.4.0", "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "psr/container": "^1.0", "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.3" + "symfony/phpunit-bridge": "^3.4.19|^4.1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.35-dev" + "dev-master": "1.38-dev" } }, "autoload": { @@ -2753,7 +2753,7 @@ "keywords": [ "templating" ], - "time": "2018-07-13T07:12:17+00:00" + "time": "2019-03-12T18:45:24+00:00" }, { "name": "typo3/phar-stream-wrapper", @@ -4166,6 +4166,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2015-10-02T06:51:40+00:00" }, { diff --git a/core/composer.json b/core/composer.json index eaf6e3850aa..694ac3413b5 100644 --- a/core/composer.json +++ b/core/composer.json @@ -32,7 +32,7 @@ "symfony/polyfill-iconv": "^1.0", "symfony/yaml": "~3.4.5", "typo3/phar-stream-wrapper": "^2.0.1", - "twig/twig": "^1.35.0", + "twig/twig": "^1.38.2", "doctrine/common": "^2.5", "doctrine/annotations": "^1.2", "guzzlehttp/guzzle": "^6.2.1", diff --git a/core/lib/Drupal/Core/Template/TwigNodeTrans.php b/core/lib/Drupal/Core/Template/TwigNodeTrans.php index ceccb68f3be..6bef53d9d4b 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeTrans.php +++ b/core/lib/Drupal/Core/Template/TwigNodeTrans.php @@ -2,6 +2,8 @@ namespace Drupal\Core\Template; +use Twig\Node\CheckToStringNode; + /** * A class that defines the Twig 'trans' tag for Drupal. * @@ -116,6 +118,9 @@ class TwigNodeTrans extends \Twig_Node { $n = $n->getNode('node'); } + if ($n instanceof CheckToStringNode) { + $n = $n->getNode('expr'); + } $args = $n; // Support TwigExtension->renderVar() function in chain. @@ -137,6 +142,9 @@ class TwigNodeTrans extends \Twig_Node { } $args = $args->getNode('node'); } + if ($args instanceof CheckToStringNode) { + $args = $args->getNode('expr'); + } if ($args instanceof \Twig_Node_Expression_GetAttr) { $argName = []; // Reuse the incoming expression. diff --git a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php index 9888caad881..2f51e721a6f 100644 --- a/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php +++ b/core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php @@ -2,6 +2,9 @@ namespace Drupal\twig_extension_test\TwigExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; + /** * A test Twig extension that adds a custom function and a custom filter. */ @@ -21,7 +24,7 @@ class TestExtension extends \Twig_Extension { */ public function getFunctions() { return [ - new \Twig_SimpleFunction('testfunc', [$this, 'testFunction']), + 'testfunc' => new TwigFunction('testfunc', ['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFunction']), ]; } @@ -39,7 +42,7 @@ class TestExtension extends \Twig_Extension { */ public function getFilters() { return [ - new \Twig_SimpleFilter('testfilter', [$this, 'testFilter']), + 'testfilter' => new TwigFilter('testfilter', ['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFilter']), ]; } diff --git a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php index 2446289984e..da02b2ba8a8 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\system\Functional\Theme; use Drupal\Tests\BrowserTestBase; +use Twig\TemplateWrapper; /** * Tests Twig registry loader. @@ -33,7 +34,7 @@ class TwigRegistryLoaderTest extends BrowserTestBase { * Checks to see if a value is a Twig template. */ public function assertTwigTemplate($value, $message = '', $group = 'Other') { - $this->assertTrue($value instanceof \Twig_Template, $message, $group); + $this->assertTrue($value instanceof TemplateWrapper, $message, $group); } /** diff --git a/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php b/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php index 4ffd2558f07..87a9801ec12 100644 --- a/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php +++ b/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\system\Kernel\Theme; use Drupal\KernelTests\KernelTestBase; +use Twig\TemplateWrapper; /** * Tests Twig namespaces. @@ -33,7 +34,7 @@ class TwigNamespaceTest extends KernelTestBase { * Checks to see if a value is a twig template. */ public function assertTwigTemplate($value, $message = '', $group = 'Other') { - $this->assertTrue($value instanceof \Twig_Template, $message, $group); + $this->assertTrue($value instanceof TemplateWrapper, $message, $group); } /**