diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 61328a2..b295297 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -226,15 +226,11 @@ protected function loadOverrides(array $names) { * The key of the cached config object to update. */ protected function propagateCacheableDependencyOverrides($cache_key) { - $overrides = ['contexts' => [], 'tags' => [], 'max_age' => Cache::PERMANENT]; foreach ($this->configFactoryOverrides as $override) { - $overrides['contexts'] = Cache::mergeContexts($overrides['contexts'], $override->getCacheContexts()); - $overrides['tags'] = Cache::mergeTags($overrides['tags'], $override->getCacheTags()); - $overrides['max_age'] = Cache::mergeMaxAges($overrides['max_age'], $override->getCacheMaxAge()); + $this->cache[$cache_key]->addRuntimeCacheContexts($override->getCacheContexts()); + $this->cache[$cache_key]->addRuntimeCacheTags($override->getCacheTags()); + $this->cache[$cache_key]->setRuntimeCacheMaxAge($override->getCacheMaxAge()); } - $this->cache[$cache_key]->addRuntimeCacheContexts($overrides['contexts']); - $this->cache[$cache_key]->addRuntimeCacheTags($overrides['tags']); - $this->cache[$cache_key]->setRuntimeCacheMaxAge($overrides['max_age']); } /** diff --git a/core/modules/config/src/Tests/CacheContextConfigOverrideTest.php b/core/modules/config/src/Tests/CacheContextConfigOverrideTest.php index 38cbb42..90aee2a 100644 --- a/core/modules/config/src/Tests/CacheContextConfigOverrideTest.php +++ b/core/modules/config/src/Tests/CacheContextConfigOverrideTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\config_override_test\Cache\PirateDayCacheContext; use Drupal\Core\Cache\Cache; use Drupal\simpletest\KernelTestBase; @@ -35,8 +36,8 @@ public function testConfigOverride() { // Check that the cacheable properties are correct. $this->assertEqual(['pirate_day'], $config->getCacheContexts()); - $this->assertEqual(['config:system.theme'], $config->getCacheTags()); - $this->assertEqual(Cache::PERMANENT, $config->getCacheMaxAge()); + $this->assertEqual(['config:system.theme', 'pirate-day-tag'], $config->getCacheTags()); + $this->assertEqual(PirateDayCacheContext::PIRATE_DAY_MAX_AGE, $config->getCacheMaxAge()); } } diff --git a/core/modules/config/tests/config_override_test/src/Cache/PirateDayCacheContext.php b/core/modules/config/tests/config_override_test/src/Cache/PirateDayCacheContext.php index 44c344f..80e6000 100644 --- a/core/modules/config/tests/config_override_test/src/Cache/PirateDayCacheContext.php +++ b/core/modules/config/tests/config_override_test/src/Cache/PirateDayCacheContext.php @@ -17,6 +17,11 @@ class PirateDayCacheContext implements CacheContextInterface { /** + * The length of Pirate Day. It lasts 24 hours. + */ + const PIRATE_DAY_MAX_AGE = 86400; + + /** * {@inheritdoc} */ public static function getLabel() { diff --git a/core/modules/config/tests/config_override_test/src/PirateDayCacheContextConfigOverride.php b/core/modules/config/tests/config_override_test/src/PirateDayCacheContextConfigOverride.php index 20f8303..f7e016d 100644 --- a/core/modules/config/tests/config_override_test/src/PirateDayCacheContextConfigOverride.php +++ b/core/modules/config/tests/config_override_test/src/PirateDayCacheContextConfigOverride.php @@ -8,7 +8,6 @@ namespace Drupal\config_override_test; use Drupal\config_override_test\Cache\PirateDayCacheContext; -use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; @@ -56,14 +55,14 @@ public function getCacheContexts() { * {@inheritdoc} */ public function getCacheTags() { - return []; + return ['pirate-day-tag']; } /** * {@inheritdoc} */ public function getCacheMaxAge() { - return Cache::PERMANENT; + return PirateDayCacheContext::PIRATE_DAY_MAX_AGE; } }