- Issue created by @prudloff
We noticed that cache tags added by a hook_block_view_BASE_BLOCK_ID_alter() was not bubbled correctly on some of our blocks. It was blocks from the block_group module and these blocks implement MainContentBlockPluginInterface.
It seems to be caused by this code: https://git.drupalcode.org/project/drupal/-/blob/d81484de177f105e751a288...
viewMultiple() calls buildPreRenderableBlock() which triggers the hook_block_view_BASE_BLOCK_ID_alter hooks.
But the result of buildPreRenderableBlock() is merged with +=
which means the returned #cache will be ignored and it will keep the one it already has.
Add a hook like this:
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function foo_block_view_page_title_block_alter(array &$build) {
$build['#cache']['tags'][] = 'foo';
}
Inspect the X-Drupal-Cache-Tags header of the response, it does not contain this cache tag.
BlockViewBuilder::viewMultiple() should merge the cache metadata returned by BlockViewBuilder::buildPreRenderableBlock().
Active
11.0 🔥
cache system