Issue #3039408 by vijaycs85, WidgetsBurritos, alexpott, phenaproxima, Joseph Zhao, tstoeckler, kfritsche, mikelutz, fabpot: Updating twig/twig to v1.38.0 or v1.38.1 causes fatal error

merge-requests/1119/head
Nathaniel Catchpole 2019-03-13 13:20:40 +00:00
parent 30654bd41d
commit 82fed91529
6 changed files with 28 additions and 14 deletions

19
composer.lock generated
View File

@ -2021,7 +2021,7 @@
}, },
{ {
"name": "Gert de Pagter", "name": "Gert de Pagter",
"email": "BackEndTea@gmail.com" "email": "backendtea@gmail.com"
} }
], ],
"description": "Symfony polyfill for ctype functions", "description": "Symfony polyfill for ctype functions",
@ -2691,31 +2691,31 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.35.4", "version": "v1.38.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "7e081e98378a1e78c29cc9eba4aefa5d78a05d2a" "reference": "874adbd9222f928f6998732b25b01b41dff15b0c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7e081e98378a1e78c29cc9eba4aefa5d78a05d2a", "url": "https://api.github.com/repos/twigphp/Twig/zipball/874adbd9222f928f6998732b25b01b41dff15b0c",
"reference": "7e081e98378a1e78c29cc9eba4aefa5d78a05d2a", "reference": "874adbd9222f928f6998732b25b01b41dff15b0c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.4.0",
"symfony/polyfill-ctype": "^1.8" "symfony/polyfill-ctype": "^1.8"
}, },
"require-dev": { "require-dev": {
"psr/container": "^1.0", "psr/container": "^1.0",
"symfony/debug": "^2.7", "symfony/debug": "^2.7",
"symfony/phpunit-bridge": "^3.3" "symfony/phpunit-bridge": "^3.4.19|^4.1.8"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.35-dev" "dev-master": "1.38-dev"
} }
}, },
"autoload": { "autoload": {
@ -2753,7 +2753,7 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2018-07-13T07:12:17+00:00" "time": "2019-03-12T18:45:24+00:00"
}, },
{ {
"name": "typo3/phar-stream-wrapper", "name": "typo3/phar-stream-wrapper",
@ -4166,6 +4166,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"abandoned": true,
"time": "2015-10-02T06:51:40+00:00" "time": "2015-10-02T06:51:40+00:00"
}, },
{ {

View File

@ -32,7 +32,7 @@
"symfony/polyfill-iconv": "^1.0", "symfony/polyfill-iconv": "^1.0",
"symfony/yaml": "~3.4.5", "symfony/yaml": "~3.4.5",
"typo3/phar-stream-wrapper": "^2.0.1", "typo3/phar-stream-wrapper": "^2.0.1",
"twig/twig": "^1.35.0", "twig/twig": "^1.38.2",
"doctrine/common": "^2.5", "doctrine/common": "^2.5",
"doctrine/annotations": "^1.2", "doctrine/annotations": "^1.2",
"guzzlehttp/guzzle": "^6.2.1", "guzzlehttp/guzzle": "^6.2.1",

View File

@ -2,6 +2,8 @@
namespace Drupal\Core\Template; namespace Drupal\Core\Template;
use Twig\Node\CheckToStringNode;
/** /**
* A class that defines the Twig 'trans' tag for Drupal. * A class that defines the Twig 'trans' tag for Drupal.
* *
@ -116,6 +118,9 @@ class TwigNodeTrans extends \Twig_Node {
$n = $n->getNode('node'); $n = $n->getNode('node');
} }
if ($n instanceof CheckToStringNode) {
$n = $n->getNode('expr');
}
$args = $n; $args = $n;
// Support TwigExtension->renderVar() function in chain. // Support TwigExtension->renderVar() function in chain.
@ -137,6 +142,9 @@ class TwigNodeTrans extends \Twig_Node {
} }
$args = $args->getNode('node'); $args = $args->getNode('node');
} }
if ($args instanceof CheckToStringNode) {
$args = $args->getNode('expr');
}
if ($args instanceof \Twig_Node_Expression_GetAttr) { if ($args instanceof \Twig_Node_Expression_GetAttr) {
$argName = []; $argName = [];
// Reuse the incoming expression. // Reuse the incoming expression.

View File

@ -2,6 +2,9 @@
namespace Drupal\twig_extension_test\TwigExtension; 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. * 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() { public function getFunctions() {
return [ 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() { public function getFilters() {
return [ return [
new \Twig_SimpleFilter('testfilter', [$this, 'testFilter']), 'testfilter' => new TwigFilter('testfilter', ['Drupal\twig_extension_test\TwigExtension\TestExtension', 'testFilter']),
]; ];
} }

View File

@ -3,6 +3,7 @@
namespace Drupal\Tests\system\Functional\Theme; namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Twig\TemplateWrapper;
/** /**
* Tests Twig registry loader. * Tests Twig registry loader.
@ -33,7 +34,7 @@ class TwigRegistryLoaderTest extends BrowserTestBase {
* Checks to see if a value is a Twig template. * Checks to see if a value is a Twig template.
*/ */
public function assertTwigTemplate($value, $message = '', $group = 'Other') { public function assertTwigTemplate($value, $message = '', $group = 'Other') {
$this->assertTrue($value instanceof \Twig_Template, $message, $group); $this->assertTrue($value instanceof TemplateWrapper, $message, $group);
} }
/** /**

View File

@ -3,6 +3,7 @@
namespace Drupal\Tests\system\Kernel\Theme; namespace Drupal\Tests\system\Kernel\Theme;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Twig\TemplateWrapper;
/** /**
* Tests Twig namespaces. * Tests Twig namespaces.
@ -33,7 +34,7 @@ class TwigNamespaceTest extends KernelTestBase {
* Checks to see if a value is a twig template. * Checks to see if a value is a twig template.
*/ */
public function assertTwigTemplate($value, $message = '', $group = 'Other') { public function assertTwigTemplate($value, $message = '', $group = 'Other') {
$this->assertTrue($value instanceof \Twig_Template, $message, $group); $this->assertTrue($value instanceof TemplateWrapper, $message, $group);
} }
/** /**