diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 52d91fd..6c2e354 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -159,7 +159,6 @@ protected function setOverriddenData() { } if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) { $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->settingsOverrides), TRUE); - $this->overriddenData['isImmutable'] = TRUE; } return $this; } @@ -286,7 +285,6 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { } if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) { $original_data = NestedArray::mergeDeepArray(array($original_data, $this->settingsOverrides), TRUE); - $original_data['isImmutable'] = TRUE; } } @@ -305,4 +303,17 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { } } + /** + * Returns whether this configuration contains any overrides. + * + * @return bool + * TRUE if it contains any, FALSE otherwise. + */ + public function containsOverrides() { + return (isset($this->overriddenData) || + (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) || + (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) + ); + } + } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index b6a63b7..800ac9c 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -184,7 +184,15 @@ protected function doLoadMultiple(array $ids = NULL) { $records = []; foreach ($this->configFactory->loadMultiple($names) as $config) { $id = $config->get($this->idKey); - $records[$id] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get(); + if ($this->overrideFree) { + $record = $config->getOriginal(NULL, FALSE); + } else { + $record = $config->get(); + if ($config->containsOverrides()) { + $record['isImmutable'] = TRUE; + } + } + $records[$id] = $record; $configs[$id] = $config; } $entities = $this->mapFromStorageRecords($records, $configs); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityOverrideTest.php index 4a5e2dd..a5d3317 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityOverrideTest.php @@ -83,12 +83,16 @@ function testConfEntityOverride() { self::assertSame($config_entity_data['weight'], $expected_original_data['weight']); // try saving override values + $thrown_exception = NULL; try { /** @var \Drupal\config_test\Entity\ConfigTest $config_entity */ $config_entity = $config_test_storage->load('dotted.default'); $config_entity->weight = 240; $config_entity->save(); - } catch (\Exception $e) {} + } catch (\Exception $e) { + $thrown_exception = $e; + } + self::assertNotNull($thrown_exception); // Verify that it contains the overridden data from $config. $config_entity = $config_test_storage->load('dotted.default');