From 4eeed9dbb5615eff9772ff851e986d3c0f6760cc Mon Sep 17 00:00:00 2001 From: xandeadx Date: Wed, 5 May 2021 19:02:22 +0500 Subject: [PATCH] Issue #3212340 by xandeadx: drupal_block() show fatal error if block plugin return NULL --- src/View/BlockViewBuilder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/View/BlockViewBuilder.php b/src/View/BlockViewBuilder.php index ab42b2c..d0adc1e 100644 --- a/src/View/BlockViewBuilder.php +++ b/src/View/BlockViewBuilder.php @@ -135,8 +135,9 @@ class BlockViewBuilder { if ($block_plugin instanceof TitleBlockPluginInterface) { $build['content']['#cache']['contexts'][] = 'url'; } - - if ($wrapper && !Element::isEmpty($build['content'])) { + // Some blocks returns NULL instead of array when empty. + // @see https://www.drupal.org/project/drupal/issues/3212354 + if ($wrapper && is_array($build['content']) && !Element::isEmpty($build['content'])) { $build += [ '#theme' => 'block', '#id' => $configuration['id'] ?? NULL,