diff --git a/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php b/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php index fecd97027c05a89c6ba3cbec7688bc06973299dd..da16e918adfa67952424e6b8aecde7023d99d09c 100644 --- a/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php +++ b/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Menu\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Cache\Cache; use Drupal\Core\Menu\LocalActionManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -94,7 +95,7 @@ public function build() { * {@inheritdoc} */ public function getCacheContexts() { - return ['route']; + return Cache::mergeContexts(parent::getCacheContexts(), ['route']); } } diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php index 1a686220ae0482affbcbac30f1b674734ec7b6a6..846c2854cfed19b7581b6470d9260779e5395ebe 100644 --- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php @@ -9,6 +9,7 @@ use Drupal\Core\Block\BlockBase; use Drupal\book\BookManagerInterface; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -182,12 +183,7 @@ public function build() { * {@inheritdoc} */ public function getCacheContexts() { - // The "Book navigation" block must be cached per role and book navigation - // context. - return [ - 'user.roles', - 'route.book_navigation', - ]; + return Cache::mergeContexts(parent::getCacheContexts(), ['user.roles', 'route.book_navigation']); } /** diff --git a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php index 53b07272bcde8ae91c1e7f65f23c26065d95946d..7c14fdcb7d0ad6d2fe6b38cc7eb1e99673d78a74 100644 --- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php +++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; @@ -87,14 +88,14 @@ public function blockSubmit($form, FormStateInterface $form_state) { * {@inheritdoc} */ public function getCacheContexts() { - return ['user.node_grants:view']; + return Cache::mergeContexts(parent::getCacheContexts(), ['user.node_grants:view']); } /** * {@inheritdoc} */ public function getCacheTags() { - return ['node_list']; + return Cache::mergeTags(parent::getCacheTags(), ['node_list']); } } diff --git a/core/modules/help/src/Plugin/Block/HelpBlock.php b/core/modules/help/src/Plugin/Block/HelpBlock.php index 0a29dddff56e29fd9aee34e7ab1d4bd39c4bfce5..cae2b6ef8a8e2e65ba6eeab674ae37da8bb1c702 100644 --- a/core/modules/help/src/Plugin/Block/HelpBlock.php +++ b/core/modules/help/src/Plugin/Block/HelpBlock.php @@ -8,6 +8,7 @@ namespace Drupal\help\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Cache\Cache; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -120,7 +121,7 @@ public function build() { public function getCacheContexts() { // The "Help" block must be cached per URL: help is defined for a // given path, and does not come with any access restrictions. - return array('url'); + return Cache::mergeContexts(parent::getCacheContexts(), ['url']); } } diff --git a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php index aec97166cbf7beb4da606e12b520c35e53f81f3d..83a2f85e85f3b18c0970fe9f782cc349fa9961aa 100644 --- a/core/modules/system/src/Plugin/Block/SystemMenuBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemMenuBlock.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuActiveTrailInterface; use Drupal\Core\Menu\MenuLinkTreeInterface; @@ -194,9 +195,7 @@ public function getCacheContexts() { // Additional cache contexts, e.g. those that determine link text or // accessibility of a menu, will be bubbled automatically. $menu_name = $this->getDerivativeId(); - return [ - 'route.menu_active_trails:' . $menu_name, - ]; + return Cache::mergeContexts(parent::getCacheContexts(), ['route.menu_active_trails:' . $menu_name]); } }