Issue Summary

In Drupal\context\Plugin\ContextReaction\Blocks:execute() this code is used to build the block and add it's contextual links to the block #theme element render array.

// Add contextual links to block.
$content = $block->build();
if (isset($content['#contextual_links'])) {
    $blockBuild['#contextual_links'] = $content['#contextual_links'];
}

I don't quite understand the need for this as it is now invoking the block->build() twice while ::preRenderBlock actually renders the block.

I don't see this double-build issue in any other modules ex:
Drupal\block\BlockViewBuilder::buildPreRenderableBlock
Drupal\ds\Plugin\DsField\BlockBase::build

Proposed Resolution

Remove the $block->build() from Drupal\context\Plugin\ContextReaction\Blocks:execute().

CommentFileSizeAuthor
context-block-build-twice.patch737 bytesmalcolm_p
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

malcolm_p created an issue. See original summary.

nace_fr’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed this and it works. I'm moving this to "Reviewed".

  • boshtian committed ba3b7f4 on 8.x-4.x authored by malcolm_p
    Issue #3035140 by malcolm_p, nace_fric: Blocks plugin calls $block->...
boshtian’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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