diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 0c4322c..2cde0d4 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -71,19 +71,6 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface protected $configFactoryOverrides = array(); /** - * A list of configuration objects that make no sense to override. - * - * @var array - */ - protected $cannotOverride = [ - // Due to side effects of doing a module install or uninstall. - 'core.extension', - // Due to the fact that this information is cached in a way that is not - // config override aware. - 'menu_link.static.overrides' - ]; - - /** * Constructs the Config factory. * * @param \Drupal\Core\Config\StorageInterface $storage @@ -153,7 +140,7 @@ protected function doGet($name, $immutable = TRUE) { $cache_key = $this->getConfigCacheKey($name, $immutable); $this->cache[$cache_key] = $this->createConfigObject($name, $immutable); - if ($this->useOverrides && $this->canOverride($name)) { + if ($this->useOverrides) { // Get and apply any overrides. $overrides = $this->loadOverrides(array($name)); if (isset($overrides[$name])) { @@ -198,7 +185,7 @@ public function loadMultiple(array $names, $immutable = TRUE) { $this->cache[$cache_key] = $this->createConfigObject($name, $immutable); $this->cache[$cache_key]->initWithData($data); - if ($this->useOverrides && $this->canOverride($name)) { + if ($this->useOverrides) { if (isset($module_overrides[$name])) { $this->cache[$cache_key]->setModuleOverride($module_overrides[$name]); } @@ -400,16 +387,4 @@ protected function createConfigObject($name, $immutable) { return new Config($name, $this->storage, $this->eventDispatcher, $this->typedConfigManager); } - /** - * Determines is a configuration object can be overridden. - * - * @param string $name - * Configuration object name. - * - * @return bool - * Returns TRUE if the configuration object can be overridden. - */ - protected function canOverride($name) { - return !in_array($name, $this->cannotOverride); - } } diff --git a/core/lib/Drupal/Core/Config/ImmutableConfig.php b/core/lib/Drupal/Core/Config/ImmutableConfig.php index 4e0d7fe..61e7fdd 100644 --- a/core/lib/Drupal/Core/Config/ImmutableConfig.php +++ b/core/lib/Drupal/Core/Config/ImmutableConfig.php @@ -31,21 +31,21 @@ class ImmutableConfig extends Config { * {@inheritdoc} */ public function set($key, $value) { - throw new ImmutableConfigException(String::format('Can not set values on immutable configuration !name:!key', ['!name' => $this->getName(), '!key' => $key])); + throw new ImmutableConfigException(String::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); } /** * {@inheritdoc} */ public function clear($key) { - throw new ImmutableConfigException(String::format('Can not clear !key key in immutable configuration !name', ['!name' => $this->getName(), '!key' => $key])); + throw new ImmutableConfigException(String::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); } /** * {@inheritdoc} */ public function save() { - throw new ImmutableConfigException(String::format('Can not save immutable configuration !name', ['!name' => $this->getName()])); + throw new ImmutableConfigException(String::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); } /** @@ -55,7 +55,7 @@ public function save() { * The configuration object. */ public function delete() { - throw new ImmutableConfigException(String::format('Can not delete immutable configuration !name', ['!name' => $this->getName()])); + throw new ImmutableConfigException(String::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); } } diff --git a/core/lib/Drupal/Core/Config/ImmutableConfigException.php b/core/lib/Drupal/Core/Config/ImmutableConfigException.php index 1537e2e..4df074a 100644 --- a/core/lib/Drupal/Core/Config/ImmutableConfigException.php +++ b/core/lib/Drupal/Core/Config/ImmutableConfigException.php @@ -12,5 +12,5 @@ * * @see \Drupal\Core\Config\ImmutableConfig */ -class ImmutableConfigException extends \RuntimeException { +class ImmutableConfigException extends \LogicException { } diff --git a/core/tests/Drupal/Tests/Core/Config/ImmutableConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ImmutableConfigTest.php index ff17640..8b0bbf8 100644 --- a/core/tests/Drupal/Tests/Core/Config/ImmutableConfigTest.php +++ b/core/tests/Drupal/Tests/Core/Config/ImmutableConfigTest.php @@ -34,7 +34,7 @@ protected function setUp() { /** * @covers ::set * @expectedException \Drupal\Core\Config\ImmutableConfigException - * @expectedExceptionMessage Can not set values on immutable configuration test:name + * @expectedExceptionMessage Can not set values on immutable configuration test:name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object */ public function testSet() { $this->config->set('name', 'value'); @@ -43,7 +43,7 @@ public function testSet() { /** * @covers ::clear * @expectedException \Drupal\Core\Config\ImmutableConfigException - * @expectedExceptionMessage Can not clear name key in immutable configuration test + * @expectedExceptionMessage Can not clear name key in immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object */ public function testClear() { $this->config->clear('name'); @@ -52,7 +52,7 @@ public function testClear() { /** * @covers ::save * @expectedException \Drupal\Core\Config\ImmutableConfigException - * @expectedExceptionMessage Can not save immutable configuration test + * @expectedExceptionMessage Can not save immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object */ public function testSave() { $this->config->save(); @@ -61,7 +61,7 @@ public function testSave() { /** * @covers ::delete * @expectedException \Drupal\Core\Config\ImmutableConfigException - * @expectedExceptionMessage Can not delete immutable configuration test + * @expectedExceptionMessage Can not delete immutable configuration test. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object */ public function testDelete() { $this->config->delete(); diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 53d31d9..1ca1110 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -586,7 +586,18 @@ * the default settings.php. * * Note that any values you provide in these variable overrides will not be - * modifiable from the Drupal administration interface. + * viewable from the Drupal administration interface. The administration + * interface displays the values stored in configuration so that you can stage + * changes to other environments that don't have the overrides. + * + * There are particular configuration values that are risky to override. For + * example, overriding the list of installed modules in 'core.extension' is not + * supported as module install or uninstall has not occurred. Other examples + * include field storage configuration, because it has effects on database + * structure, and 'core.menu.static_menu_link_overrides' since this is cached in + * a way that is not config override aware. Also, note that changing + * configuration values in settings.php will not fire any of the configuration + * change events. */ # $config['system.site']['name'] = 'My Drupal site'; # $config['system.theme']['default'] = 'stark';