From 7d6dd41846e0c1c63fef319cdb0711ec9e6de659 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 21 Aug 2024 13:21:09 -0400 Subject: [PATCH] Twig 3.12 --- CHANGELOG-WIP.md | 1 + composer.json | 2 +- composer.lock | 72 +++++++++++++++--------------- src/helpers/Template.php | 4 +- src/web/twig/nodes/GetAttrNode.php | 3 +- src/web/twig/nodes/NavNode.php | 2 +- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index 133039a0bd1..e3dd855e172 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -7,3 +7,4 @@ ### System - MySQL mutex locks and PHP session names are now namespaced using the application ID combined with the environment name. ([#15313](https://github.com/craftcms/cms/issues/15313)) +- Updated Twig to 3.12. ([#15568](https://github.com/craftcms/cms/discussions/15568)) diff --git a/composer.json b/composer.json index 83f01af6f0c..a1ca1bd2584 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "symfony/var-dumper": "^5.0|^6.0", "symfony/yaml": "^5.2.3", "theiconic/name-parser": "^1.2", - "twig/twig": "~3.8.0", + "twig/twig": "~3.12.0", "voku/stringy": "^6.4.0", "webonyx/graphql-php": "~14.11.5", "yiisoft/yii2": "~2.0.51.0", diff --git a/composer.lock b/composer.lock index 0f8ec20c9b0..6538575b136 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ff4440519cdf5a9c93257cd6c0355367", + "content-hash": "f40f892a401bc1bd015a55a86cf64e5c", "packages": [ { "name": "cebe/markdown", @@ -4075,16 +4075,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -4098,9 +4098,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -4137,7 +4134,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -4153,7 +4150,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-iconv", @@ -4492,16 +4489,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -4515,9 +4512,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -4555,7 +4549,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -4571,7 +4565,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/polyfill-php72", @@ -4813,16 +4807,16 @@ }, { "name": "symfony/polyfill-php81", - "version": "v1.27.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af", "shasum": "" }, "require": { @@ -4830,9 +4824,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -4872,7 +4863,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0" }, "funding": [ { @@ -4888,7 +4879,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/process", @@ -5331,30 +5322,37 @@ }, { "name": "twig/twig", - "version": "v3.8.0", + "version": "v3.12.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" + "reference": "4d19472d4ac1838e0b1f0e029ce1fa4040eb34ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", - "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/4d19472d4ac1838e0b1f0e029ce1fa4040eb34ea", + "reference": "4d19472d4ac1838e0b1f0e029ce1fa4040eb34ea", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php80": "^1.22" + "symfony/polyfill-php81": "^1.29" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" + "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, "type": "library", "autoload": { + "files": [ + "src/Resources/core.php", + "src/Resources/debug.php", + "src/Resources/escaper.php", + "src/Resources/string_loader.php" + ], "psr-4": { "Twig\\": "src/" } @@ -5387,7 +5385,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.8.0" + "source": "https://github.com/twigphp/Twig/tree/v3.12.0" }, "funding": [ { @@ -5399,7 +5397,7 @@ "type": "tidelift" } ], - "time": "2023-11-21T18:54:41+00:00" + "time": "2024-08-29T09:51:12+00:00" }, { "name": "voku/anti-xss", diff --git a/src/helpers/Template.php b/src/helpers/Template.php index bb14776b75f..8f3151d9e8f 100644 --- a/src/helpers/Template.php +++ b/src/helpers/Template.php @@ -14,6 +14,7 @@ use craft\web\View; use Twig\Environment; use Twig\Error\RuntimeError; +use Twig\Extension\CoreExtension; use Twig\Extension\SandboxExtension; use Twig\Markup; use Twig\Source; @@ -25,7 +26,6 @@ use yii\base\UnknownPropertyException; use yii\db\Query; use yii\db\QueryInterface; -use function twig_get_attribute; /** * Class Template @@ -145,7 +145,7 @@ public static function attribute( } try { - return twig_get_attribute( + return CoreExtension::getAttribute( $env, $source, $object, diff --git a/src/web/twig/nodes/GetAttrNode.php b/src/web/twig/nodes/GetAttrNode.php index df8ac1c035e..5982f702d15 100644 --- a/src/web/twig/nodes/GetAttrNode.php +++ b/src/web/twig/nodes/GetAttrNode.php @@ -15,7 +15,8 @@ use Twig\Template; /** - * GetAttrNode is an alternative to [[\Twig\Node\Expression\GetAttrExpression]], which sends attribute calls to [[TemplateHelper::attribute()]] rather than twig_get_attribute(). + * GetAttrNode is an alternative to [[\Twig\Node\Expression\GetAttrExpression]], which sends attribute calls to + * [[TemplateHelper::attribute()]] rather than CoreExtension::getAttribute(). * * @author Pixel & Tonic, Inc. * @since 3.0.0 diff --git a/src/web/twig/nodes/NavNode.php b/src/web/twig/nodes/NavNode.php index 725c7638a57..a50fb445a29 100644 --- a/src/web/twig/nodes/NavNode.php +++ b/src/web/twig/nodes/NavNode.php @@ -44,7 +44,7 @@ public function __construct(AssignNameExpression $keyTarget, AssignNameExpressio $this->navItemNode = new NavItem_Node($valueTarget, $indent, $outdent, $lowerBody, $lineno, $tag); $body = new Node([$this->navItemNode, $upperBody]); - parent::__construct($keyTarget, $valueTarget, $seq, null, $body, null, $lineno, $tag); + parent::__construct($keyTarget, $valueTarget, $seq, null, $body, null, $lineno); } /**