diff -u b/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php --- b/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -638,4 +638,17 @@ } + /** + * Gets the raw data without overrides. + * + * @return array + * The raw data. + */ + public function getRawData() { + if (!$this->isLoaded) { + $this->load(); + } + return $this->data; + } + } diff -u b/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php --- b/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -443,11 +443,13 @@ * The configuration event. */ public function onConfigSave(ConfigEvent $event) { - // Clear out any other cache keys apart from the config object being saved. + // Ensure that the static cache contains up to date configuration objects by + // replacing the data on any entries for the configuration object apart + // from the one that references the actual config object being saved. $saved_config = $event->getConfig(); foreach ($this->getCacheKeys($saved_config->getName()) as $cache_key) { if ($this->cache[$cache_key] != $saved_config) { - unset($this->cache[$cache_key]); + $this->cache[$cache_key]->setData($saved_config->getRawData()); } } } diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php @@ -124,9 +124,19 @@ $this->assertTrue($config->isNew(), 'The configuration object config_test.new is new'); $this->assertIdentical($config->get('key'), 'override'); \Drupal::configFactory()->disableOverrides(); - $config = \Drupal::config('config_test.new'); - $this->assertIdentical($config->get('key'), NULL); + $config_raw = \Drupal::config('config_test.new'); + $this->assertIdentical($config_raw->get('key'), NULL); + $config_raw + ->set('key', 'raw') + ->set('new_key', 'new_value') + ->save(); \Drupal::configFactory()->enableOverrides(); + // Ensure override is preserved but all other data has been updated + // accordingly. + $this->assertIdentical($config->get('key'), 'override'); + $this->assertIdentical($config->get('new_key'), 'new_value'); + $raw_data = $config->getRawData(); + $this->assertIdentical($raw_data['key'], 'raw'); } }