\Drupal\Core\Template\TwigNodeTrans should check the data attribute exists before asking for it

Created on 8 November 2024, 14 days ago

Problem/Motivation

\Drupal\Core\Template\TwigNodeTrans::compileString calls $text .= $node->getAttribute('data'); without checking if the $node has the data attribute.
This results in an uncaught logic exception.

Steps to reproduce

Add a twig node visitor that modifies a PrintNode inside a {% trans %} tag.
Have the visitor return a new series of nodes to wrap the original node.
See the uncaught exception

Proposed resolution

Remaining tasks

Only call getAttribute if the attribute exists.
If the node can't be handled at that point, probably need to loop and call compileString recursively

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024