Error when saving Layout Builder node

Created on 1 April 2025, 4 days ago

Problem/Motivation

When saving a Layout Builder-enabled node, PHP warnings are displayed in dev environments, while a WSOD is presented in production environments (due to PHP error / warning display configuration).

Warning: Undefined variable $def in Drupal\entity_usage\Plugin\EntityUsage\Track\LayoutBuilder->getTargetEntities() (line 85 of modules/contrib/entity_usage/src/Plugin/EntityUsage/Track/LayoutBuilder.php).

Steps to reproduce

Create a node that uses Layout Builder custom blocks. Save the node. Note that this is not always consistent. Some nodes do save without error.

Proposed resolution

Replace line 85's use of $def['id']: elseif ($def['id'] === 'block_content') { with elseif ($pluginId === 'block_content') {, using the $pluginId variable that is used elsewhere in this block for this particular condition.

Remaining tasks

Issue MR and Patch

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinb623

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

Comments & Activities

Production build 0.71.5 2024