Problem/Motivation

WebformBlock.php > build() function can return NULL instead of an array. If other functions have strict type checking for the output of the function it will cause an error.

Steps to reproduce

$content = $webform_block->build();
test($content);

function test(array $content) {
  //do something;
}

Proposed resolution

Since Drupal/Core/Block/BlockPluginInterface.php specifies an array is returned, this function should do so rather than other functions accepting array or NULL.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

onedotover created an issue. See original summary.

onedotover’s picture

StatusFileSize
new521 bytes
jrockowitz’s picture

Status: Active » Needs review
marcusvsouza’s picture

StatusFileSize
new521 bytes

The patch in comment # 2 has been corrupted, I made a new patch, please review it.
It is exactly the same as the previous patch, which for some reason has been corrupted.

jrockowitz’s picture

Can you please show how the patch from #2 is corrupted? The byte size is identical.

marcusvsouza’s picture

StatusFileSize
new177.29 KB

When I try to apply the patch the error in the image below tells me that the patch has been corrupted.

jrockowitz’s picture

That seems specific to your system.

BTW, a good hack if you have curl is

curl https://www.drupal.org/files/issues/2021-04-07/3207641-block-null-return.patch | git apply -

marcusvsouza’s picture

Assigned: Unassigned » marcusvsouza
Status: Needs review » Reviewed & tested by the community

The patch in the comment #2 works good using curl, thanks for the tip.
Changing to RTBC!

  • marcusvsouza authored bd006ae on 8.x-5.x
    Issue #3207641 by marcusvsouza, onedotover: WebformBlock build function...
  • marcusvsouza authored bd006ae on 8.x-5.x
    Issue #3207641 by marcusvsouza, onedotover: WebformBlock build function...

  • marcusvsouza authored bd006ae on 6.x
    Issue #3207641 by marcusvsouza, onedotover: WebformBlock build function...
  • marcusvsouza authored bd006ae on 6.x
    Issue #3207641 by marcusvsouza, onedotover: WebformBlock build function...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed
Webform logo This ticket was completed using Open Collective funds.
Please consider joining the Webform module's Open Collective to help ensure that the Webform module is maintained.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.