diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index cdfa67e..9b92879 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -74,7 +74,7 @@ class Config { * * @var array */ - protected $originalData; + protected $originalData = array(); /** * The current runtime data. diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index f61141b..d7ec22a 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -262,13 +262,10 @@ public function rename($old_name, $new_name) { unset($this->cache[$old_cache_key]); } - $new_cache_key = $this->getCacheKey($new_name); - $this->cache[$new_cache_key] = new Config($new_name, $this->storage, $this->eventDispatcher, $this->typedConfigManager, $this->language); - if ($data = $this->storage->read($new_name)) { - $this->cache[$new_cache_key]->initWithData($data); - } - $this->eventDispatcher->dispatch(ConfigEvents::RENAME, new ConfigRenameEvent($this->cache[$new_cache_key], $old_name)); - return $this->cache[$new_cache_key]; + // Prime the cache and load the configuration with the correct overrides. + $config = $this->get($new_name); + $this->eventDispatcher->dispatch(ConfigEvents::RENAME, new ConfigRenameEvent($config, $old_name)); + return $config; } /** diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEventsTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEventsTest.php index 1f17e13..1331033 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEventsTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEventsTest.php @@ -48,8 +48,7 @@ function testConfigEvents() { $this->assertIdentical($event['event_name'], ConfigEvents::SAVE); $this->assertIdentical($event['current_config_data'], array('key' => 'initial')); $this->assertIdentical($event['raw_config_data'], array('key' => 'initial')); - // The original data should be NULL for new config objects. - $this->assertIdentical($event['original_config_data'], NULL); + $this->assertIdentical($event['original_config_data'], array()); $config->set('key', 'updated')->save(); $event = \Drupal::state()->get('config_events_test.event', array()); @@ -73,7 +73,8 @@ function testConfigRenameEvent() { $name = 'config_events_test.test'; $new_name = 'config_events_test.test_rename'; - $conf['config_events_test.test']['key'] = 'overridden'; + $conf[$name] = array('key' => 'overridden'); + $conf[$new_name] = array('key' => 'new overridden'); $config = \Drupal::config($name); $config->set('key', 'initial')->save(); @@ -84,7 +85,7 @@ function testConfigRenameEvent() { $event = \Drupal::state()->get('config_events_test.event', array()); $this->assertIdentical($event['event_name'], ConfigEvents::RENAME); - $this->assertIdentical($event['current_config_data'], array('key' => 'overridden')); - $this->assertIdentical($event['raw_config_data'], array('key' => 'overridden')); - $this->assertIdentical($event['original_config_data'], array('key' => 'overridden')); + $this->assertIdentical($event['current_config_data'], array('key' => 'new overridden')); + $this->assertIdentical($event['raw_config_data'], array('key' => 'initial')); + $this->assertIdentical($event['original_config_data'], array('key' => 'new overridden')); }