Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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()
.
Comment | File | Size | Author |
---|---|---|---|
context-block-build-twice.patch | 737 bytes | malcolm_p | |
Comments
Comment #2
nace_fr CreditAttribution: nace_fr at Agiledrop - Your Trusted Drupal Teammates commentedI have reviewed this and it works. I'm moving this to "Reviewed".
Comment #4
boshtian CreditAttribution: boshtian at Agiledrop - Your Trusted Drupal Teammates commented