Commit b3150847 authored by alexpott's avatar alexpott

Issue #2541344 by Wim Leers, borisson_, DietrichM, Xano, tim.plunkett,...

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)
parent 30c69604
......@@ -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']);
}
}
......@@ -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']);
}
/**
......
......@@ -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']);
}
}
......@@ -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']);
}
}
......@@ -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]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment