core/modules/views/src/Entity/View.php | 5 ++++- core/modules/views/src/Plugin/views/display/DisplayPluginBase.php | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index cdd74ef..4978ae0 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -328,7 +328,10 @@ protected function addCacheMetadata() { $display =& $this->getDisplay($display_id); $executable->setDisplay($display_id); - list($display['cache_metadata']['max_age'], $display['cache_metadata']['contexts'], $display['cache_metadata']['tags']) = $executable->getDisplay()->calculateCacheMetadata(); + $cache_metadata = $executable->getDisplay()->calculateCacheMetadata(); + $display['cache_metadata']['max_age'] = $cache_metadata->getCacheMaxAge(); + $display['cache_metadata']['contexts'] = $cache_metadata->getCacheContexts(); + $display['cache_metadata']['tags'] = $cache_metadata->getCacheTags(); // Always include at least the 'languages:' context as there will most // probably be translatable strings in the view output. $display['cache_metadata']['contexts'] = Cache::mergeContexts($display['cache_metadata']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE]); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index e217466..92c393f 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -2276,7 +2276,9 @@ public function calculateCacheMetadata () { // Iterate over ordinary views plugins. foreach (Views::getPluginTypes('plugin') as $plugin_type) { $plugin = $this->getPlugin($plugin_type); - $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($plugin)); + if ($plugin instanceof CacheableDependencyInterface) { + $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($plugin)); + } } // Iterate over all handlers. Note that at least the argument handler will @@ -2284,7 +2286,9 @@ public function calculateCacheMetadata () { foreach (array_keys(Views::getHandlerTypes()) as $handler_type) { $handlers = $this->getHandlers($handler_type); foreach ($handlers as $handler) { - $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($handler)); + if ($handler instanceof CacheableDependencyInterface) { + $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($handler)); + } } }