diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index c0d2617..889f1cc 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -263,12 +263,14 @@ protected function replaceData(array $data) { * * @param array $data * The overridden values of the configuration data. + * @param bool $force + * Force the override (used for global overrides). * * @return Drupal\Core\Config\Config * The configuration object. */ - public function setOverride(array $data) { - $this->context->setOverrides($this->getName(), $data); + public function setOverride(array $data, $force = FALSE) { + $this->context->setOverrides($this->getName(), $data, $force); $this->resetOverriddenData(); return $this; } diff --git a/core/lib/Drupal/Core/Config/Context/ConfigContext.php b/core/lib/Drupal/Core/Config/Context/ConfigContext.php index a5382fd..5f31b56 100644 --- a/core/lib/Drupal/Core/Config/Context/ConfigContext.php +++ b/core/lib/Drupal/Core/Config/Context/ConfigContext.php @@ -110,7 +110,7 @@ public function notify($config_event_name, Config $config = NULL) { /** * Implements \Drupal\Core\Config\Context\ContextInterface::setOverride(). */ - public function setOverrides($config_name, $data) { + public function setOverrides($config_name, $data, $force = FALSE) { if (!isset($this->overrides[$config_name])) { $this->overrides[$config_name] = $data; } diff --git a/core/lib/Drupal/Core/Config/Context/ContextInterface.php b/core/lib/Drupal/Core/Config/Context/ContextInterface.php index 46dbcbb..78fb3ca 100644 --- a/core/lib/Drupal/Core/Config/Context/ContextInterface.php +++ b/core/lib/Drupal/Core/Config/Context/ContextInterface.php @@ -84,8 +84,10 @@ public function notify($config_event_name, Config $config = NULL); * Configuration name. * @param array data * The override data. + * @param bool $force + * Force the override (used for global overrides). */ - public function setOverrides($config_name, $data); + public function setOverrides($config_name, $data, $force = FALSE); /** * Gets the override data for a configuration object. diff --git a/core/lib/Drupal/Core/Config/Context/FreeConfigContext.php b/core/lib/Drupal/Core/Config/Context/FreeConfigContext.php index 4307f97..a140365 100644 --- a/core/lib/Drupal/Core/Config/Context/FreeConfigContext.php +++ b/core/lib/Drupal/Core/Config/Context/FreeConfigContext.php @@ -23,7 +23,7 @@ public function getOverrides($config_name) { /** * Implements \Drupal\Core\Config\Context\ContextInterface::setOverride(). */ - public function setOverrides($config_name, $data) { + public function setOverrides($config_name, $data, $force = FALSE) { // Do nothing as this is override free. } diff --git a/core/lib/Drupal/Core/Config/Context/OnlyForcedConfigContext.php b/core/lib/Drupal/Core/Config/Context/OnlyForcedConfigContext.php new file mode 100644 index 0000000..e3556d5 --- /dev/null +++ b/core/lib/Drupal/Core/Config/Context/OnlyForcedConfigContext.php @@ -0,0 +1,25 @@ +setFactoryMethod('get') ->addTag('persist'); - // Register a config context with no overrides for use in administration - // forms, enabling modules and importing configuration. + // Register a config context with only forced overrides for use in + // administration forms, enabling modules and importing configuration. + $container->register('config.context.only.forced', 'Drupal\Core\Config\Context\ContextInterface') + ->setFactoryService(new Reference('config.context.factory')) + ->setFactoryMethod('get') + ->addArgument('Drupal\Core\Config\Context\OnlyForcedConfigContext'); + + // Register a config context with no overrides for use in + // internal configuration operations, such as import. $container->register('config.context.free', 'Drupal\Core\Config\Context\ContextInterface') ->setFactoryService(new Reference('config.context.factory')) ->setFactoryMethod('get') diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigGlobalOverrideSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigGlobalOverrideSubscriber.php index 02bf2cb..58390ee 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigGlobalOverrideSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigGlobalOverrideSubscriber.php @@ -27,7 +27,7 @@ public function configInit(ConfigEvent $event) { $config = $event->getConfig(); if (isset($conf[$config->getName()])) { - $config->setOverride($conf[$config->getName()]); + $config->setOverride($conf[$config->getName()], TRUE); } } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 58e6d58..a072f76 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1406,7 +1406,7 @@ function system_modules_uninstall_submit($form, &$form_state) { * @see system_settings_form() */ function system_site_information_settings($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $site_config = config('system.site'); $site_mail = $site_config->get('mail'); if (empty($site_mail)) { @@ -1513,7 +1513,7 @@ function system_site_information_settings_validate($form, &$form_state) { * Form submission handler for system_site_information_settings(). */ function system_site_information_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('system.site') ->set('name', $form_state['values']['site_name']) ->set('mail', $form_state['values']['site_mail']) @@ -1530,7 +1530,7 @@ function system_site_information_settings_submit($form, &$form_state) { * @ingroup forms */ function system_cron_settings($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $form['description'] = array( '#markup' => '
' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '
', ); @@ -1568,7 +1568,7 @@ function system_cron_settings($form, &$form_state) { * @ingroup forms */ function system_cron_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('system.cron') ->set('threshold.autorun', $form_state['values']['cron_safe_threshold']) ->save(); @@ -1598,7 +1598,7 @@ function system_run_cron_submit($form, &$form_state) { * @see system_logging_settings_submit() */ function system_logging_settings($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $form['error_level'] = array( '#type' => 'radios', '#title' => t('Error messages to display'), @@ -1621,7 +1621,7 @@ function system_logging_settings($form, &$form_state) { * @ingroup forms */ function system_logging_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('system.logging') ->set('error_level', $form_state['values']['error_level']) ->save(); @@ -1635,7 +1635,7 @@ function system_logging_settings_submit($form, &$form_state) { */ function system_performance_settings($form, &$form_state) { drupal_add_library('system', 'drupal.system'); - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $config = config('system.performance'); $form['clear_cache'] = array( @@ -1725,7 +1725,7 @@ function system_performance_settings($form, &$form_state) { * @ingroup forms */ function system_performance_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $config = config('system.performance'); $config->set('cache.page.use_internal', $form_state['values']['cache']); $config->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']); @@ -1871,7 +1871,7 @@ function system_image_toolkit_settings() { * @ingroup forms */ function system_rss_feeds_settings($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $rss_config = config('system.rss'); $form['feed_description'] = array( '#type' => 'textarea', @@ -1907,7 +1907,7 @@ function system_rss_feeds_settings($form, &$form_state) { * @ingroup forms */ function system_rss_feeds_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('system.rss') ->set('channel.description', $form_state['values']['feed_description']) ->set('items.limit', $form_state['values']['feed_default_items']) @@ -2028,7 +2028,7 @@ function system_regional_settings_submit($form, &$form_state) { * @see system_site_maintenance_mode_submit() */ function system_site_maintenance_mode($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $config = config('system.maintenance'); $form['maintenance_mode'] = array( '#type' => 'checkbox', @@ -2051,7 +2051,7 @@ function system_site_maintenance_mode($form, &$form_state) { * @ingroup forms */ function system_site_maintenance_mode_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('system.maintenance') ->set('enabled', $form_state['values']['maintenance_mode']) ->set('message', $form_state['values']['maintenance_mode_message']) diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index c3931d8..c37070c 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -292,7 +292,7 @@ function user_admin_account_validate($form, &$form_state) { * @see user_admin_settings_submit() */ function user_admin_settings($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); $config = config('user.settings'); $mail_config = config('user.mail'); @@ -639,7 +639,7 @@ function user_admin_settings($form, &$form_state) { * Form submission handler for user_admin_settings(). */ function user_admin_settings_submit($form, &$form_state) { - config_context_enter('config.context.free'); + config_context_enter('config.context.only.forced'); config('user.settings') ->set('anonymous', $form_state['values']['anonymous']) ->set('admin_role', $form_state['values']['user_admin_role'])