PHP message: Error: Call to a member function getEntityTypeId() on null (Layout Builder)

Created on 19 April 2019, about 6 years ago
Updated 18 April 2023, about 2 years 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

One of the following changes to \Drupal\layout_builder\Plugin\Block\InlineBlock::getEntity():

  1. allow for returning NULL (in which case all callers must account for that)
  2. throw an exception when the block cannot be loaded
  3. ALWAYS return a block (not sure that it's possible)

Remaining tasks

Write tests
Decide on a resolution

User interface changes

TBD

API changes

TBD

Data model changes

N/A

Release notes snippet

N/A

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
Layout builderย  โ†’

Last updated 20 minutes 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.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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