summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-10-30 16:25:58 +0000
committerAlex Pott2015-10-30 16:25:58 +0000
commitb3150847e054778746e7bebc59693b35839431e2 (patch)
tree8a28e94cc206645ce0a5019ce46eab8efcf58cbc
parent30c696045997aa75769bcbc39e9023cbc99f771d (diff)
Issue #2541344 by Wim Leers, borisson_, DietrichM, Xano, tim.plunkett, alvar0hurtad0, joshi.rohit100: BlockBase subclasses should merge their cache tags/contexts with the parent's (BlockBase's)
-rw-r--r--core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php3
-rw-r--r--core/modules/book/src/Plugin/Block/BookNavigationBlock.php8
-rw-r--r--core/modules/forum/src/Plugin/Block/ForumBlockBase.php5
-rw-r--r--core/modules/help/src/Plugin/Block/HelpBlock.php3
-rw-r--r--core/modules/system/src/Plugin/Block/SystemMenuBlock.php5
5 files changed, 11 insertions, 13 deletions
diff --git a/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php b/core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php
index fecd970..da16e91 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 @@ class LocalActionsBlock extends BlockBase implements ContainerFactoryPluginInter
* {@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 1a68622..846c285 100644
--- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
+++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php
@@ -9,6 +9,7 @@ namespace Drupal\book\Plugin\Block;
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 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
* {@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 53b0727..7c14fdc 100644
--- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
+++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php
@@ -9,6 +9,7 @@ namespace Drupal\forum\Plugin\Block;
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 @@ abstract class ForumBlockBase extends BlockBase {
* {@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 0a29ddd..cae2b6e 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 @@ class HelpBlock extends BlockBase implements ContainerFactoryPluginInterface {
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 aec9716..83a2f85 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 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
// 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]);
}
}