diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index cf2248b..8c343c8 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -213,6 +213,13 @@ public function setNegotiationMethodId($method_id) { } /** + * {@inheritdoc} + */ + public function getCacheTag() { + return array('langcode' => $this->getId()); + } + + /** * Sort language objects. * * @param array $languages diff --git a/core/lib/Drupal/Core/Language/LanguageInterface.php b/core/lib/Drupal/Core/Language/LanguageInterface.php index e718749..2b53d85 100644 --- a/core/lib/Drupal/Core/Language/LanguageInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageInterface.php @@ -208,4 +208,12 @@ public function getNegotiationMethodId(); */ public function setNegotiationMethodId($method_id); + /** + * The unique cache tag associated with this language. + * + * @return array + * An array containing the language cache tag. + */ + public function getCacheTag(); + } diff --git a/core/modules/block/src/BlockBase.php b/core/modules/block/src/BlockBase.php index a2f5e17..cf153c0 100644 --- a/core/modules/block/src/BlockBase.php +++ b/core/modules/block/src/BlockBase.php @@ -447,7 +447,10 @@ public function getCacheTags() { // cache tag that affects all instances of this block: across themes and // across regions. $block_plugin_cache_tag = str_replace(':', '__', $this->getPluginID()); - return array('block_plugin' => array($block_plugin_cache_tag)); + return array_merge( + array('block_plugin' => array($block_plugin_cache_tag)), + \Drupal::languageManager()->getCurrentLanguage()->getCacheTag() + ); } /** diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index ebd4a7c..9539880 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -297,6 +297,7 @@ public function testBlockCacheTags() { 'block_view:1', 'block:powered', 'block_plugin:system_powered_by_block', + 'langcode:en', 'rendered:1', ); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); @@ -306,6 +307,7 @@ public function testBlockCacheTags() { 'block:powered', 'theme:stark', 'block_plugin:system_powered_by_block', + 'langcode:en', 'rendered:1', ); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); @@ -338,6 +340,7 @@ public function testBlockCacheTags() { 'block:powered-2', 'block:powered', 'block_plugin:system_powered_by_block', + 'langcode:en', 'rendered:1', ); $this->assertEqual($cache_entry->tags, $expected_cache_tags); @@ -346,6 +349,7 @@ public function testBlockCacheTags() { 'block:powered', 'theme:stark', 'block_plugin:system_powered_by_block', + 'langcode:en', 'rendered:1', ); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:en:stark'); @@ -355,6 +359,7 @@ public function testBlockCacheTags() { 'block:powered-2', 'theme:stark', 'block_plugin:system_powered_by_block', + 'langcode:en', 'rendered:1', ); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:en:stark'); diff --git a/core/modules/block/src/Tests/BlockViewBuilderTest.php b/core/modules/block/src/Tests/BlockViewBuilderTest.php index 38969e8..b7ec21a 100644 --- a/core/modules/block/src/Tests/BlockViewBuilderTest.php +++ b/core/modules/block/src/Tests/BlockViewBuilderTest.php @@ -219,7 +219,7 @@ public function testBlockViewBuilderAlter() { $request->setMethod('GET'); $default_keys = array('entity_view', 'block', 'test_block', 'en', 'cache_context.theme'); - $default_tags = array('block_view' => TRUE, 'block' => array('test_block'), 'theme' => 'stark', 'block_plugin' => array('test_cache')); + $default_tags = array('block_view' => TRUE, 'block' => array('test_block'), 'theme' => 'stark', 'block_plugin' => array('test_cache'), 'langcode' => 'en'); // Advanced: cached block, but an alter hook adds an additional cache key. $this->setBlockCacheConfig(array( @@ -234,7 +234,7 @@ public function testBlockViewBuilderAlter() { $this->assertIdentical(drupal_render($build), ''); $cache_entry = $this->container->get('cache.render')->get($cid); $this->assertTrue($cache_entry, 'The block render element has been cached with the expected cache ID.'); - $expected_flattened_tags = array('block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache', 'rendered:1'); + $expected_flattened_tags = array('block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache','langcode:en', 'rendered:1'); $this->assertIdentical($cache_entry->tags, $expected_flattened_tags, 'The block render element has been cached with the expected cache tags.'); $this->container->get('cache.render')->delete($cid); @@ -248,7 +248,7 @@ public function testBlockViewBuilderAlter() { $this->assertIdentical(drupal_render($build), ''); $cache_entry = $this->container->get('cache.render')->get($cid); $this->assertTrue($cache_entry, 'The block render element has been cached with the expected cache ID.'); - $expected_flattened_tags = array('block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache', $alter_add_tag . ':1', 'rendered:1'); + $expected_flattened_tags = array('block_view:1', 'block:test_block', 'theme:stark', 'block_plugin:test_cache', 'langcode:en', $alter_add_tag . ':1', 'rendered:1'); $this->assertIdentical($cache_entry->tags, $expected_flattened_tags, 'The block render element has been cached with the expected cache tags.'); $this->container->get('cache.render')->delete($cid); diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index d3d63be..c35077e 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -8,6 +8,7 @@ namespace Drupal\config_translation\Form; use Drupal\config_translation\ConfigMapperManagerInterface; +use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Config; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\TypedConfigManagerInterface; @@ -235,6 +236,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->mapper->getOverviewRoute(), $this->mapper->getOverviewRouteParameters() ); + + Cache::invalidateTags($this->language->getCacheTag()); } /** diff --git a/core/modules/menu_ui/src/Tests/MenuCacheTagsTest.php b/core/modules/menu_ui/src/Tests/MenuCacheTagsTest.php index 4a19182..ef451e7 100644 --- a/core/modules/menu_ui/src/Tests/MenuCacheTagsTest.php +++ b/core/modules/menu_ui/src/Tests/MenuCacheTagsTest.php @@ -50,6 +50,7 @@ public function testMenuBlock() { $expected_tags = array( 'theme:stark', 'theme_global_settings:1', + 'langcode:en', 'rendered:1', 'block_view:1', 'block:' . $block->id(), diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php index 6dbfb51..c00644c 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -68,6 +68,7 @@ function testPageCacheTags() { // Full node page 1. $this->verifyPageCacheTags('node/' . $node_1->id(), array( + 'langcode:en', 'rendered:1', 'theme:bartik', 'theme_global_settings:1', @@ -93,6 +94,7 @@ function testPageCacheTags() { // Full node page 2. $this->verifyPageCacheTags('node/' . $node_2->id(), array( + 'langcode:en', 'rendered:1', 'theme:bartik', 'theme_global_settings:1',