Allow other Twig node visitors to modify 'display_start' and 'display_end'

Created on 20 July 2023, over 1 year ago
Updated 18 June 2024, 5 months ago

Problem/Motivation

A Twig node visitor enhances a template when an SDC component is found (modules/sdc/src/Twig/ComponentNodeVisitor.php).
The node visitor replaces 'display_start' and 'display_end' with its nodes, ignoring that other modules may have added something to them.

In particular, the Tracer module (used by WebProfiler) is adding some code to trace the template render time.

Steps to reproduce

* install a fresh copy of Drupal 10.1.*
* enable the SDC module, define a component, and add it to a page
* navigate to the page that contains the SDC component, everything work as expected
* download and enable WebProfiler (that in turn downloads and enables Tracer)
* navigate to the page that contains the SDC component
* the page broke with an error like this: Error: Call to a member function leave() on null in __TwigTemplate_355dee1e190651c61ec8a29afeb99829->doDisplay() (line 120 of /tmp/twig/64b904e4040f3_bocconi_ds:bds-header_bF4EXNuRh-ABv7SRE3u1qRweA/gyEYJRegggYskrr-GXJO_VBdHtvR8cGZlDzRANParpA.php).

Proposed resolution

Append information SDC needs to 'display_start' and 'display_end' Twig nodes instead of replacing them.

Remaining tasks

Review the MR

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

📌 Task
Status

Fixed

Version

10.1

Component
single-directory components 

Last updated 2 days ago

Created by

🇮🇹Italy lussoluca Italy

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

Comments & Activities

Production build 0.71.5 2024