core/modules/block/src/Tests/BlockSystemBrandingTest.php | 11 +++++++++++ core/modules/system/src/Plugin/Block/SystemBrandingBlock.php | 11 ++++++----- core/modules/user/src/Form/UserPasswordResetForm.php | 2 +- core/modules/user/src/Tests/UserLoginTest.php | 2 ++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/modules/block/src/Tests/BlockSystemBrandingTest.php b/core/modules/block/src/Tests/BlockSystemBrandingTest.php index 82cff41..448a1ca 100644 --- a/core/modules/block/src/Tests/BlockSystemBrandingTest.php +++ b/core/modules/block/src/Tests/BlockSystemBrandingTest.php @@ -38,6 +38,12 @@ protected function setUp() { * Tests system branding block configuration. */ public function testSystemBrandingSettings() { + $assert_cache_tags = function() { + $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); + $this->assertTrue(in_array('config:system.site', $cache_tags)); + $this->assertTrue(in_array('theme_global_setting', $cache_tags)); + }; + $site_logo_xpath = '//div[@id="block-site-branding"]//a[@class="site-logo"]'; $site_name_xpath = '//div[@id="block-site-branding"]//div[@class="site-name"]'; $site_slogan_xpath = '//div[@id="block-site-branding"]//div[@class="site-slogan"]'; @@ -51,6 +57,7 @@ public function testSystemBrandingSettings() { $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); + $assert_cache_tags(); // Turn just the logo off. $this->config('block.block.site-branding') @@ -64,6 +71,7 @@ public function testSystemBrandingSettings() { $this->assertTrue(empty($site_logo_element), 'The branding block logo was disabled.'); $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); + $assert_cache_tags(); // Turn just the site name off. $this->config('block.block.site-branding') @@ -78,6 +86,7 @@ public function testSystemBrandingSettings() { $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); $this->assertTrue(empty($site_name_element), 'The branding block site name was disabled.'); $this->assertTrue(!empty($site_slogan_element), 'The branding block slogan was found.'); + $assert_cache_tags(); // Turn just the site slogan off. $this->config('block.block.site-branding') @@ -92,6 +101,7 @@ public function testSystemBrandingSettings() { $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); $this->assertTrue(!empty($site_name_element), 'The branding block site name was found.'); $this->assertTrue(empty($site_slogan_element), 'The branding block slogan was disabled.'); + $assert_cache_tags(); // Turn the site name and the site slogan off. $this->config('block.block.site-branding') @@ -106,6 +116,7 @@ public function testSystemBrandingSettings() { $this->assertTrue(!empty($site_logo_element), 'The branding block logo was found.'); $this->assertTrue(empty($site_name_element), 'The branding block site name was disabled.'); $this->assertTrue(empty($site_slogan_element), 'The branding block slogan was disabled.'); + $assert_cache_tags(); } } diff --git a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php index 1d99bb3..7dd5c54 100644 --- a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -189,11 +190,11 @@ public function build() { * {@inheritdoc} */ public function getCacheTags() { - // The theme-specific cache tag is set automatically for each block, but the - // output of this block also depends on the global theme settings. - $cache_tags = parent::getCacheTags(); - $cache_tags[] = 'theme_global_setting'; - return $cache_tags; + return Cache::mergeTags( + parent::getCacheTags(), + ['theme_global_setting'], + $this->configFactory->get('system.site')->getCacheTags() + ); } } diff --git a/core/modules/user/src/Form/UserPasswordResetForm.php b/core/modules/user/src/Form/UserPasswordResetForm.php index 490965a..69b4588 100644 --- a/core/modules/user/src/Form/UserPasswordResetForm.php +++ b/core/modules/user/src/Form/UserPasswordResetForm.php @@ -97,7 +97,7 @@ public function buildForm(array $form, FormStateInterface $form_state, AccountIn } /** - * {@inheritdoc}o + * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var $user \Drupal\user\UserInterface */ diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php index 1ffdddc..6f85658 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -23,6 +23,8 @@ class UserLoginTest extends WebTestBase { function testCacheTags() { $this->drupalGet('user/login'); $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); + // The user login form says "Enter your username.", hence it + // depends on config:system.site, and its cache tags should be present. $this->assertTrue(in_array('config:system.site', $cache_tags)); }