diff --git a/core/includes/config.inc b/core/includes/config.inc index aa7e3a8..7684ff4 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -5,8 +5,14 @@ use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\ConfigException; /** - * The value a module should return from hook_config_sync() to indicate that - * it should be called again by the config system during this sync. + * Flag to indicate that synchronization of module configuration depends on other configuration. + * + * hook_config_sync() implementations should return this value to indicate that + * the configuration changes cannot be applied yet and the hook implementation + * should be called again later during the synchronization. + * + * @todo Find a better value, or possibly replace with simple Boolean return + * value for hook_config_sync(). */ const CONFIG_DEFER_SYNC = 'CONFIG_DEFER_SYNC'; @@ -106,17 +112,20 @@ function config($name, $config_class = NULL, $storage_class = NULL) { * Synchronizes configuration from FileStorage to DatabaseStorage. */ function config_sync() { - $config_changes = config_get_changes_from_disk(); + $config_changes = config_sync_get_changes(); if (empty($config_changes)) { return; } - $lock_name = __FUNCTION__; - if (!lock_acquire($lock_name)) { + if (!lock_acquire(__FUNCTION__)) { // Another request is synchronizing configuration. Wait for it to complete, - // then re-check for any remaining differences. - lock_wait($lock_name); - return config_sync(); + // then return a negative result for UI purposes. We do not make a + // difference between an actual synchronization error and a failed lock, + // because a concurrent request synchronizing configuration is an edge-case + // in the first place and would mean that more than one developer or + // site builder attempts to do it without coordinating with others. + lock_wait(__FUNCTION__); + return FALSE; } try { @@ -128,10 +137,10 @@ function config_sync() { catch (ConfigException $e) { watchdog_exception('config_sync', $e); config_sync_invoke_sync_error_hooks($config_changes); - lock_release($lock_name); + lock_release(__FUNCTION__); return FALSE; } - lock_release($lock_name); + lock_release(__FUNCTION__); return TRUE; } @@ -261,13 +270,13 @@ function config_sync_sort_dependencies(array $modules) { } /** - * Returns a list of changes on disk compared to the active store. + * Returns a list of differences between FileStorage and DatabaseStorage. * * @return array|bool * The list of files changed on disk compared to the active store, or FALSE if * there are no differences. */ -function config_get_changes_from_disk() { +function config_sync_get_changes() { $disk_config_names = FileStorage::getNamesWithPrefix(); $active_config_names = DatabaseStorage::getNamesWithPrefix(); $config_changes = array( diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 1169bc0..f63dcd3 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -11,11 +11,11 @@ * @see config_admin_import_form_submit() */ function config_admin_import_form($form, &$form_state) { - $config_changes = config_get_changes_from_disk(); + $config_changes = config_sync_get_changes(); if (empty($config_changes)) { $form['no_changes'] = array( - '#markup' => 'There are no changes on disk to reload.' + '#markup' => t('There are no configuration changes.'), ); return $form; } @@ -49,10 +49,10 @@ function config_admin_import_form($form, &$form_state) { */ function config_admin_import_form_submit($form, &$form_state) { if (config_sync()) { - drupal_set_message('Configuration successfully reloaded from disk.'); + drupal_set_message(t('The configuration was imported successfully.')); } else { - drupal_set_message('There was an error reloading configuration from disk.', 'error'); + drupal_set_message(t('The import failed due to an error. Any errors have been logged.'), 'error'); } }