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
Issue fork drupal-3375843
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dieterholvoet commentedComment #4
e0ipsoIMO (at a first glance) this is also a stable blocker.
Comment #5
e0ipsoChanged base branch.
Comment #7
e0ipsoRe-rolled against 11.x and fixed some phpcs issues to allow tests to run. Thanks @lussoluca and @DieterHolvoet!!
Comment #8
e0ipsoHmmm, for some reason the GitLab UI to generate a new branch from 11.x did not work as I was expecting. I updated it manually.
Comment #9
e0ipsoComment #10
e0ipsoAll tests are passing. This confirms the static code review.
Next step before RTBC is for @lussoluca to confirm that the current MR (on the updated 11.x branch) works along with the Tracer module.
Comment #11
lussolucaI confirm that everything still works as expected
Comment #12
e0ipsoConfirming the RTBC based on my code review, the green tests, and Luca's manual testing.
Comment #13
lauriiiIs this something we could test in core? Maybe we could write a test module that does something similar to Tracer to make sure that we don't break this.
Comment #14
lussolucaI can work on it.
Comment #15
smustgrave commentedLeaving assigned to @lussoluca.
Moving to NW per #13
Comment #16
lussolucaTest added, let me know if it's ok
Comment #17
smustgrave commentedOnly rebased to run the test-only run and tests failed as expected
Looking at the change it makes sense and does seem to solve the issue.
Tested on Umami which has SDC enabled with a disclaimer component.
Comment #21
lauriiiCrediting @DieterHolvoet for working on #3376785: Error: Call to a member function leave() on null which I believe is a duplicate.
Committed a6aabb7 and pushed to 11.x. Also cherry-picked to 10.2.x and 10.1.x. Thanks!