Problem/Motivation

BlockPluginInterface defines build() method that is supposed to return an array.
However, AggregatorFeedBlock returns NULL when configured feed is not loaded.

Proposed resolution

Return empty array when feed cannot be loaded.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chi created an issue. See original summary.

Chi’s picture

Title: AggregatorFeedBlock » AggregatorFeedBlock::build must always return array
guilhermevp’s picture

Status: Active » Needs review
FileSize
4.5 KB

A patch for it.

Chi’s picture

Status: Needs review » Needs work

The patch includes a bunch of unrelated changes.

guilhermevp’s picture

Status: Needs work » Needs review
FileSize
460 bytes

Sorry for wrong patch.

Chi’s picture

@guilhermevp I would use early return instead of "else".
Example: https://git.drupalcode.org/project/drupal/-/blob/9.1.8/core/modules/help...

guilhermevp’s picture

Right, makes sense. Thanks for the feedback!

Chi’s picture

@guilhermevp That's not early return but rather the opposite.

https://pear.php.net/manual/en/standards.bestpractices.php#standards.bes...

guilhermevp’s picture

Sorry, thanks again for the feedback.
Sending patch.

guilhermevp’s picture

removed indentation error.

Chi’s picture

Status: Needs review » Reviewed & tested by the community

Thank you.

  • catch committed ebf0c95 on 9.3.x
    Issue #3212354 by guilhermevp, Chi: AggregatorFeedBlock::build must...

  • catch committed ff99906 on 9.2.x
    Issue #3212354 by guilhermevp, Chi: AggregatorFeedBlock::build must...

  • catch committed d39e25d on 9.1.x
    Issue #3212354 by guilhermevp, Chi: AggregatorFeedBlock::build must...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Don't think it's useful to add an explicit test for this.

Committed/pushed to 9.3.x, cherry-picked to 9.2.x and 9.1.x, thanks!

Status: Fixed » Closed (fixed)

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