Commit a9b064cc authored by catch's avatar catch

Issue #2395511 by alexpott, Gábor Hojtsy: Config static cache is not cleared properly on rename

parent d05559a3
......@@ -219,8 +219,9 @@ public function reset($name = NULL) {
*/
public function rename($old_name, $new_name) {
$this->storage->rename($old_name, $new_name);
$old_cache_key = $this->getConfigCacheKey($old_name);
if (isset($this->cache[$old_cache_key])) {
// Clear out the static cache of any references to the old name.
foreach ($this->getConfigCacheKeys($old_name) as $old_cache_key) {
unset($this->cache[$old_cache_key]);
}
......
......@@ -128,13 +128,26 @@ function testCRUD() {
// Test renaming when config.factory does not have the object in its static
// cache.
$config_factory = $this->container->get('config.factory');
$name = 'config_test.crud_rename';
// Turn off overrides and pollute the non-overrides static cache.
$config_factory->setOverrideState(FALSE);
\Drupal::config($name);
// Turn on overrides and pollute the overrides static cache.
$config_factory->setOverrideState(TRUE);
$config = \Drupal::config($name);
// Rename and ensure that happened properly.
$new_name = 'config_test.crud_rename_no_cache';
$this->container->get('config.factory')->clearStaticCache()->rename($name, $new_name);
$config_factory->rename($name, $new_name);
$renamed_config = \Drupal::config($new_name);
$this->assertIdentical($renamed_config->get(), $config->get());
$this->assertIdentical($renamed_config->isNew(), FALSE);
// Ensure the overrides static cache has been cleared.
$this->assertIdentical(\Drupal::config($name)->isNew(), TRUE);
// Ensure the non-overrides static cache has been cleared.
$config_factory->setOverrideState(FALSE);
$this->assertIdentical(\Drupal::config($name)->isNew(), TRUE);
$config_factory->setOverrideState(TRUE);
// Merge data into the configuration object.
$new_config = \Drupal::config($new_name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment