Improve debugability of block plugins returning NULL in Layout Builder

Created on 31 July 2020, over 4 years ago
Updated 26 January 2023, about 2 years ago

Problem/Motivation

Placing a block that returns NULL will trigger
TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given, called in /app/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php on line 110 in Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() (line 149 of /app/web/core/lib/Drupal/Core/Cache/CacheableMetadata.php)

BlockPluginInterface::build() is documented as always returning an array, but was written before PHP7 allowed for strict return types.

Proposed resolution

Adding an assert() here improves debugability

Remaining tasks

None

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

📌 Task
Status

Needs work

Version

10.1

Component
Layout builder 

Last updated 1 day ago

Created by

🇺🇸United States nicxvan

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