Error: Call to a member function leave() on null

Created on 25 July 2023, almost 2 years ago

Problem/Motivation

Sometimes when Twig debugging is disabled, SDC Twig template compilation seems to fail with the following error:

Error: Call to a member function leave() on null in file [...]/web/sites/default/files/php/twig/64bf9e0bd0c77_same_page_preview:setting_UAdx53yvzVORzVoXou1fqsv-K/c2DvwrUT2BAXYR9hT2ihhvjQ_WgTJm6o1hzJlVVW0TE.php on line 59

For me, it happened with a same_page_preview component.

I was able to track down the root cause. Drupal\sdc\Twig\ComponentNodeVisitor overwrites nodes under display_start at fixed indexes. display_start has a EnterProfileNode as first node and display_end has a LeaveProfileNode as first node. If ComponentNodeVisitor overwrites the EnterProfileNode without overwriting the LeaveProfileNode, the error above is triggered.

Steps to reproduce

I'm not sure under what exact circumstances this happens, it depends very much on the structure of the template and whether Twig debugging is enabled.

Proposed resolution

Not sure yet, will have to look into it further.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
single-directory components 

Last updated 3 days ago

Created by

🇧🇪Belgium dieterholvoet Brussels

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

Comments & Activities

Production build 0.71.5 2024