Twig development mode breaks pages with SDC

Created on 4 March 2025, 29 days ago

Problem/Motivation

I started noticing a PHP WSOD today and after some xdebug'ing, traced it back to ๐Ÿ“Œ SDC *.component.yml metadata is cached aggressively, gets in the way of component development Active :

TypeError: Drupal\Core\Plugin\DefaultPluginManager::doGetDefinition(): Argument #1 ($definitions) must be of type array, null given, called in /var/www/html/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php on line 25 in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 43 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Steps to reproduce

  • Install Drupal standard profile
  • Login and enable Twig development mode
  • Visit a page that uses an SDC, eg. front page of the site, or any Olivero page. You may need to rebuild cache if you had already visited this page before turning on Twig development mode
  • ๐Ÿ’ฅ Above error

Reviewing the MR, the overridden getDefinitions method does not call the parent method when Twig debugging is on. What appears to be missing in relation to the parent is a call to $this->setCachedDefinitions, which in turn sets $this->definitions, which is depended on in the place where the error occurs.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.1 ๐Ÿ”ฅ

Component

single-directory components

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada m4olivei Grimsby, ON

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024