Log error + visual warning for missing or broken block

Created on 19 April 2019, over 5 years ago
Updated 5 August 2024, 4 months ago

Problem/Motivation

If a default layout has a custom block placed and overridden layouts exist, deleting the custom block from the default can trigger
Error: Call to a member function getEntityTypeId() on null in Drupal\layout_builder\Plugin\Block\InlineBlock->build() (line 218 of core/modules/layout_builder/src/Plugin/Block/InlineBlock.php).

Steps to reproduce

  1. Add a custom block to a layout default
  2. Begin editing a layout override, do not save
  3. Remove the block from the default
  4. Attempt to continue editing the layout override

Proposed resolution

If a block can not be loaded, change \Drupal\layout_builder\Plugin\Block\InlineBlock such that:

  1. a visual warning is shown to privileged users that the block is broken or missing, and
  2. log error.

Remaining tasks

User interface changes

N/A

API changes

\Drupal\layout_builder\Plugin\Block\InlineBlock::__construct now requires $logger to be passed.

Data model changes

N/A

Release notes snippet

If a default layout has a custom block placed and overridden layouts exist, deleting the custom block from the default can trigger an error in
InlineBlock->build() . A user-friendly warning message is now displayed and logged.

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Layout builderย  โ†’

Last updated 1 day ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States andyg5000 North Carolina, USA

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024