diff --git a/core/includes/config.inc b/core/includes/config.inc index 7684ff4..4a3a1f7 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -1,22 +1,11 @@ setData($source_config->get()); $target_config->save(); } @@ -178,11 +159,11 @@ function config_sync_invoke_sync_hooks(array $config_changes) { // taking the array by reference. $config_changes_copy = $config_changes; - // @todo Lock writes to ALL config storages to prevent other/unintended config + // @todo Lock writes to all storages to prevent other/unintended config // changes from happening during the import. - $target_storage = config(NULL, NULL, 'Drupal\Core\Config\DatabaseStorage'); - $source_storage = config(NULL, NULL, 'Drupal\Core\Config\FileStorage'); + $target_storage = new DrupalConfig(new DatabaseStorage(NULL)); + $source_storage = new DrupalConfig(new FileStorage(NULL)); // Allow all modules to deny configuration changes. foreach (module_implements('config_sync_validate') as $module) { @@ -191,33 +172,11 @@ function config_sync_invoke_sync_hooks(array $config_changes) { $function($config_changes, $target_storage, $source_storage); } - // We allow modules to signal that they would like to be rerun after all - // other modules by returning CONFIG_DEFER_SYNC. Loop until there are no - // modules left that indicate they would like to be re-run, checking that we - // are not stuck re-running the same list of modules infinitely. - // The list of modules is ordered by the reversed chain of module - // dependencies, in order to invoke dependent modules first, and thus decrease - // the possibility for CONFIG_DEFER_SYNC requests and increase the chance of - // being able to execute all changes in a single loop. - $modules = config_sync_sort_dependencies(module_implements('config_sync')); - do { - // Prevent an infinite loop. If the two variables stay the same, then all - // remaining modules asked to defer their import operations, which means - // that there is a unmet dependency. - $initial_module_list = $modules; - - foreach ($modules as $key => $module) { - $config_changes = $config_changes_copy; - $function = $module . '_config_sync'; - if ($function($config_changes, $target_storage, $source_storage) !== CONFIG_DEFER_SYNC) { - unset($modules[$key]); - } - } - } while ($modules && $modules != $initial_module_list); - - // If there are modules left, then we hit an infinite loop. - if ($modules) { - throw new ConfigException('Unmet dependencies detected during synchronization.'); + // Allow modules to react to the configuration changes. + foreach (module_implements('config_sync') as $module) { + $config_changes = $config_changes_copy; + $function = $module . '_config_sync'; + $function($config_changes, $target_storage, $source_storage); } } @@ -233,8 +192,8 @@ function config_sync_invoke_sync_hooks(array $config_changes) { * An array of changes to be loaded. */ function config_sync_invoke_sync_error_hooks(array $config_changes) { - $target_storage = config(NULL, NULL, 'Drupal\Core\Config\DatabaseStorage'); - $source_storage = config(NULL, NULL, 'Drupal\Core\Config\FileStorage'); + $target_storage = new DrupalConfig(new DatabaseStorage(NULL)); + $source_storage = new DrupalConfig(new FileStorage(NULL)); foreach (module_implements('config_sync_error') as $module) { $function = $module . '_config_sync_error'; @@ -249,27 +208,6 @@ function config_sync_invoke_sync_error_hooks(array $config_changes) { } /** - * Sorts a given list of modules based on their dependencies. - * - * @param array $modules - * A list of modules. - * - * @return array - * The list of modules sorted by dependency. - */ -function config_sync_sort_dependencies(array $modules) { - // Get all module data so we can find weights and sort. - $module_data = system_rebuild_module_data(); - - $sorted_modules = array(); - foreach ($modules as $module) { - $sorted_modules[$module] = $module_data[$module]->sort; - } - arsort($sorted_modules); - return array_keys($sorted_modules); -} - -/** * Returns a list of differences between FileStorage and DatabaseStorage. * * @return array|bool @@ -286,7 +224,7 @@ function config_sync_get_changes() { ); foreach (array_intersect($disk_config_names, $active_config_names) as $name) { $active_config = config($name); - $file_config = config($name, NULL, 'Drupal\Core\Config\FileStorage'); + $file_config = new DrupalConfig(new FileStorage($name)); if ($active_config->get() != $file_config->get()) { $config_changes['changed'][] = $name; } diff --git a/core/modules/config/config.api.php b/core/modules/config/config.api.php index e645c39..273936d 100644 --- a/core/modules/config/config.api.php +++ b/core/modules/config/config.api.php @@ -59,10 +59,6 @@ function hook_config_sync_validate($config_changes, $target_storage, $source_sto * A configuration class acting on the source storage from which configuration * differences were read. Use $target_storage->load() to load a configuration * object. - * - * @return - * Nothing on successful synchronization, or CONFIG_DEFER_SYNC if a change - * cannot be synchronized yet adn depends on another module to execute first. */ function hook_config_sync($config_changes, $target_storage, $source_storage) { foreach ($config_changes['new'] as $name) {