Skip to content
Snippets Groups Projects
Commit 41e5fa95 authored by N Cantrell's avatar N Cantrell Committed by Stephan Zeidler
Browse files

Issue #3153392 by cantrellnm, martin_andersn, nimoatwoodway: Page breaks if...

Issue #3153392 by cantrellnm, martin_andersn, nimoatwoodway: Page breaks if Drupal block doesn't set cache metadata in build
parent f41a285a
No related branches found
No related tags found
No related merge requests found
......@@ -144,11 +144,12 @@ class BlockFilter extends FilterBase implements ContainerFactoryPluginInterface
$block = $this->blocksRenderer->getBlockFromPluginId($attributes->blockId, []);
$build = $block->build();
$metadata['tags'] = array_merge($metadata['tags'], $build['#cache']['tags']);
$metadata['contexts'] = array_merge($metadata['contexts'], $build['#cache']['contexts']);
$metadata['tags'] = array_merge($metadata['tags'], isset($build['#cache']['tags']) ? $build['#cache']['tags'] : $block->getCacheTags());
$metadata['contexts'] = array_merge($metadata['contexts'], isset($build['#cache']['contexts']) ? $build['#cache']['contexts'] : $block->getCacheContexts());
if ($build['#cache']['max-age'] < $metadata['max-age']) {
$metadata['max-age'] = $build['#cache']['max-age'];
$max_age = isset($build['#cache']['max-age']) ? $build['#cache']['max-age'] : $block->getCacheMaxAge();
if ($max_age < $metadata['max-age']) {
$metadata['max-age'] = $max_age;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment