diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 2a3b7a5..7c2005c 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -317,7 +317,7 @@ protected function addCacheMetadata() { list($display['cache_metadata']['cacheable'], $display['cache_metadata']['contexts']) = $executable->getDisplay()->calculateCacheMetadata(); // Always include at least the language context as there will be most // probable translatable strings in the view output. - $display['cache_metadata']['contexts'][] = 'cache.context.language'; + $display['cache_metadata']['contexts'][] = 'language'; $display['cache_metadata']['contexts'] = array_unique($display['cache_metadata']['contexts']); } // Restore the previous active display. diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 14a1703..6c3ed2a 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -330,9 +330,6 @@ public function getCacheContexts() { $entity_type_id = $views_data['table']['entity type']; $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $contexts = $entity_type->getListCacheContexts(); - foreach ($contexts as $key => $context) { - $contexts[$key] = 'cache.context.' . $context; - } } return $contexts; } diff --git a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php index e9e17bd..639c4b0 100644 --- a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php +++ b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php @@ -32,13 +32,11 @@ class RenderCacheIntegrationTest extends ViewUnitTestBase { public function testBuildRenderableWithCacheContexts() { $view = View::load('test_view'); $display =& $view->getDisplay('default'); - $display['cache_metadata']['contexts'] = ['beatles_tag']; - $view->save(); - + $display['cache_metadata']['contexts'] = ['beatles']; + $executable = $view->getExecutable(); - $view = Views::getView('test_view'); - $build = $view->buildRenderable(); - $this->assertEqual(['beatles_tag'], $build['#cache']['contexts']); + $build = $executable->buildRenderable(); + $this->assertEqual(['beatles'], $build['#cache']['contexts']); } /** @@ -48,7 +46,7 @@ public function testViewAddCacheMetadata() { $view = View::load('test_display'); $view->save(); - $this->assertEqual(['cache.context.node_view_grants', 'cache.context.language'], $view->getDisplay('default')['cache_metadata']['contexts']); + $this->assertEqual(['node_view_grants', 'language'], $view->getDisplay('default')['cache_metadata']['contexts']); } }