Fix BlockViewBuilder to handle NULL and []

Created on 5 February 2025, about 1 month ago

Problem/Motivation

Follow up from πŸ“Œ Improve debugability of block plugins returning NULL in Layout Builder Needs work

From lauriii

It looks like \Drupal\block\BlockViewBuilder::preRender also explicitly adds support for NULL type, even though it's not documented to be supported. 😬 As the error suggests, there are already type hints for ensuring it is an array, meaning that it's fine to add the exception as a DX improvement. However, we probably should allow NULL as the empty value as well, since it's supported by \Drupal\block\BlockViewBuilder::preRender.

From @tim.plunkett

Good news: returning [] and NULL have exactly the same effect. We can file a follow-up to fix BlockViewBuilder which has been wrong this whole time.

Steps to reproduce

NA

Proposed resolution

Fill in

Remaining tasks

Complete summary
Implement
Review

User interface changes

NA

Introduced terminology

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

layout_builder.module

Created by

πŸ‡ΊπŸ‡ΈUnited States smustgrave

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

Comments & Activities

Production build 0.71.5 2024