diff --git a/core/modules/node/src/Plugin/views/filter/Access.php b/core/modules/node/src/Plugin/views/filter/Access.php index 0724a36..d56edcd 100644 --- a/core/modules/node/src/Plugin/views/filter/Access.php +++ b/core/modules/node/src/Plugin/views/filter/Access.php @@ -53,8 +53,7 @@ public function query() { public function getCacheContexts() { $contexts = parent::getCacheContexts(); - // Node access is potentially cacheable per user. - $contexts[] = 'user'; + $contexts[] = 'node_view_grants'; return $contexts; } diff --git a/core/modules/views/src/Entity/Render/RendererBase.php b/core/modules/views/src/Entity/Render/RendererBase.php index be8aea6..d4694d2 100644 --- a/core/modules/views/src/Entity/Render/RendererBase.php +++ b/core/modules/views/src/Entity/Render/RendererBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Language\LanguageManagerInterface; +use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\query\QueryPluginBase; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -16,7 +17,7 @@ /** * Defines a base class for entity row renderers. */ -abstract class RendererBase { +abstract class RendererBase implements CacheablePluginInterface { /** * The view executable wrapping the view storage entity. @@ -63,6 +64,20 @@ public function __construct(ViewExecutable $view, LanguageManagerInterface $lang } /** + * {@inheritdoc} + */ + public function isCacheable() { + return TRUE; + } + + /** + * {@inheritdoc} + */ + public function getCacheContexts() { + return ['language']; + } + + /** * Returns the language code associated to the given row. * * @param \Drupal\views\ResultRow $row diff --git a/core/modules/views/src/Plugin/CacheablePluginInterface.php b/core/modules/views/src/Plugin/CacheablePluginInterface.php index a8a72a9..cca8c08 100644 --- a/core/modules/views/src/Plugin/CacheablePluginInterface.php +++ b/core/modules/views/src/Plugin/CacheablePluginInterface.php @@ -8,7 +8,10 @@ namespace Drupal\views\Plugin; /** - * Provides information whether and how the specific Views plugin is cacheable. + * Provides caching information about the result cacheability of views plugins. + * + * For caaching on the render level we rely on cache bubbling of the cache + * contexts. */ interface CacheablePluginInterface { diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index 46d3f5f..e34d4a1 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -961,10 +961,7 @@ public function isCacheable() { * {@inheritdoc} */ public function getCacheContexts() { - // @todo what to do about field access? - $contexts = []; - - $contexts[] = 'user'; + $contexts = $this->getEntityTranslationRenderer()->getCacheContexts(); return $contexts; }