diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2458,9 +2458,9 @@ $container->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') ->addArgument('%config.storage.options%'); - $container->register('config.globaloverridesubscriber', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber'); + $container->register('config.subscriber.globalconf', 'Drupal\Core\EventSubscriber\ConfigGlobalOverrideSubscriber'); $container->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher') - ->addMethodCall('addSubscriber', array(new Reference('config.globaloverridesubscriber'))); + ->addMethodCall('addSubscriber', array(new Reference('config.subscriber.globalconf'))); // Register configuration object factory. $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') ->addArgument(new Reference('config.storage')) reverted: --- b/core/includes/config.inc +++ a/core/includes/config.inc @@ -65,7 +65,7 @@ * A configuration object. */ function config($name) { + return drupal_container()->get('config.factory')->get($name)->load(); - return drupal_container()->get('config.factory')->get($name); } /** @@ -195,6 +195,7 @@ $handled_by_module = FALSE; if (module_hook($module, 'config_import_' . $op)) { $old_config = new Config($name, $target_storage); + $old_config->load(); $data = $source_storage->read($name); $new_config = new Config($name, $target_storage); 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 @@ -108,7 +108,6 @@ * Returns whether this configuration object is new. */ public function isNew() { - $this->build(); return $this->isNew; } @@ -140,7 +139,9 @@ * The data that was requested. */ public function get($key = '') { - $this->build(); + if (!isset($this->overriddenData)) { + $this->setOverriddenData(); + } if (empty($key)) { return $this->overriddenData; } @@ -164,7 +165,8 @@ */ public function setData(array $data) { $this->data = $data; - return $this->rebuild(); + $this->resetOverriddenData(); + return $this; } /** @@ -177,7 +179,32 @@ */ public function setOverride(array $data) { $this->overrides = $data; - return $this->rebuild(); + $this->resetOverriddenData(); + return $this; + } + + /** + * Sets the current data for this configuration object. + * + * Merges overridden configuration data into the original data. + */ + protected function setOverriddenData() { + $this->overriddenData = $this->data; + if (!empty($this->overrides)) { + $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->overrides)); + } + return $this; + } + + /** + * Resets the current data, so overrides are re-applied. + * + * This method should be called after the original data or the overridden data + * has been changed. + */ + protected function resetOverriddenData() { + unset($this->overriddenData); + return $this; } /** @@ -189,7 +216,6 @@ * @todo */ public function set($key, $value) { - $this->build(); // Type-cast value into a string. $value = $this->castValue($value); @@ -202,7 +228,8 @@ else { NestedArray::setValue($this->data, $parts, $value); } - return $this->rebuild(); + $this->resetOverriddenData(); + return $this; } /** @@ -251,7 +278,6 @@ * Name of the key whose value should be unset. */ public function clear($key) { - $this->build(); $parts = explode('.', $key); if (count($parts) == 1) { unset($this->data[$key]); @@ -259,7 +285,8 @@ else { NestedArray::unsetValue($this->data, $parts); } - return $this->rebuild(); + $this->resetOverriddenData(); + return $this; } /** @@ -276,19 +303,18 @@ $this->setData($data); } $this->notify('load'); - return $this->rebuild(); + return $this; } /** * Saves the configuration object. */ public function save() { - $this->build(); $this->sortByKey($this->data); $this->storage->write($this->name, $this->data); $this->isNew = FALSE; $this->notify('save'); - return $this->rebuild(); + return $this; } /** @@ -318,41 +344,12 @@ $this->data = array(); $this->storage->delete($this->name); $this->isNew = TRUE; + $this->resetOverriddenData(); $this->notify('delete'); - return $this->rebuild(); - } - - /** - * Build the data for this configuration object. - * - * Loads the base data if not loaded, and builds the overriddenData runtime - * configuration computing the overridden values. - */ - public function build() { - if (!isset($this->overriddenData)) { - if (!isset($this->data)) { - $this->load(); - } - $this->overriddenData = $this->data; - if (!empty($this->overrides)) { - $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->overrides)); - } - } return $this; } /** - * Resets the current data, so overrides are re-applied. - * - * This method should be called after the original data or the overridden data - * has been changed. - */ - public function rebuild() { - unset($this->overriddenData); - return $this->build(); - } - - /** * Retrieve the storage used to load and save this configuration object. */ public function getStorage() {