Closed (fixed)
Project:
Twig Tweak
Version:
8.x-2.4
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Jan 2020 at 08:48 UTC
Updated:
22 Jun 2022 at 15:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
rcodinaComment #3
rcodinaComment #4
chi commentedThis needs steps to reproduce.
Comment #5
rcodinaI updated the main description of the issue.
Comment #6
rcodinaThe problem is that for some reason
$block_plugin->build()insideTwigExtension::drupalBlockis returning NULL for some reason. Given that PHP fatally breaks if the parameter of isEmpty is not an array, I think it would be nice to apply this patch to nicely break without breaking the whole page (even if we cannot reproduce it in a clean Drupal site).Comment #7
chi commentedDo you use contact_block module?
I've just installed it and tested on Drupal 8.9. Everything works fine.
BlockPluginInterface::build is always supposed to return array.
Comment #8
chi commentedComment #9
b-prod commentedTo reproduce:
Create a view with an exposed filter, expose it to a block, add the block to a page, then remove the exposed filter from the view.
You get the described error, as the
$build['content']is NULL, and a PHP fatal error...Comment #10
chi commentedThank you. I've managed to reproduce it now. That's actually duplicates #3212340: drupal_block() show fatal error if block plugin return NULL. Under some circumstances
ViewsExposedFilterBlock::build()returns NULL though it is supposed to return array per interface declaration. So it's a bug in Drupal Core. I've just submitted a bug report for this #3230681: ViewsExposedFilterBlock::build must always return array.Comment #11
chi commentedThe patch in #3212340: drupal_block() show fatal error if block plugin return NULL was not backported to 2.x. The provided here patch offers same fix but needs reroll.
Comment #12
chi commentedComment #14
smustgrave commentedThis appears to not be needed for the 3.x branch? Should it be added to the 2.x branch though?
Comment #15
chi commented@smustgrave, it should.
Comment #18
rpayanmComment #19
chi commentedThank you.