Browse Source

Issue #3212340 by xandeadx: drupal_block() show fatal error if block plugin return NULL

merge-requests/14/head
xandeadx 4 years ago committed by Chi
parent
commit
c336ca8a19
  1. 5
      src/View/BlockViewBuilder.php

5
src/View/BlockViewBuilder.php

@ -135,8 +135,9 @@ class BlockViewBuilder {
if ($block_plugin instanceof TitleBlockPluginInterface) { if ($block_plugin instanceof TitleBlockPluginInterface) {
$build['content']['#cache']['contexts'][] = 'url'; $build['content']['#cache']['contexts'][] = 'url';
} }
// Some blocks returns NULL instead of array when empty.
if ($wrapper && !Element::isEmpty($build['content'])) { // @see https://www.drupal.org/project/drupal/issues/3212354
if ($wrapper && is_array($build['content']) && !Element::isEmpty($build['content'])) {
$build += [ $build += [
'#theme' => 'block', '#theme' => 'block',
'#id' => $configuration['id'] ?? NULL, '#id' => $configuration['id'] ?? NULL,

Loading…
Cancel
Save