diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index cb7c3c3..f15facd 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -349,6 +349,45 @@ protected function setProcessedExtension($type, $op, $name) { } /** + * Orders newly uninstalled extensions for import. + * + * Sorts the list of newly uninstalled extensions by their weights, so that + * dependencies are uninstalled last. Extensions of the same weight are + * sorted in reverse alphabetical order, to ensure the order is exactly + * opposite from installation. + * + * @param array $extension_list + * The list of extensions to be uninstalled. + * + * @see ConfigImporter::sortInstalledExtensions() + * + * @todo Improve these docs. + */ + protected function sortUninstalledExtensions(array &$extension_list) { + array_multisort(array_values($extension_list), SORT_ASC, array_keys($extension_list), SORT_DESC, $extension_list); + + } + + /** + * Orders newly installed extensions for import. + * + * Sorts the list of newly installed extensions in reverse order of their + * weights, so that dependencies are installed first. Extensions of the same + * weight are sorted in alphabetical order, to ensure the order is exactly + * opposite from uninstallation. + * + * @param array $extension_list + * The list of extensions to be uninstalled. + * + * @see ConfigImporter::sortUninstalledExtensions() + * + * @todo Improve these docs. + */ + protected function sortInstalledExtensions(array &$extension_list) { + array_multisort(array_values($extension_list), SORT_DESC, array_keys($extension_list), SORT_ASC, $extension_list); + } + + /** * Populates the extension change list. */ protected function createExtensionChangelist() { @@ -373,15 +412,9 @@ protected function createExtensionChangelist() { // Work out what modules to install and uninstall. $uninstall = array_diff(array_keys($current_extensions['module']), array_keys($new_extensions['module'])); $install = array_diff(array_keys($new_extensions['module']), array_keys($current_extensions['module'])); - // Sort the module list by their weights. So that dependencies are - // uninstalled last. Modules of the same weight are sorted in reverse - // alphabetical order. - array_multisort(array_values($module_list), SORT_ASC, array_keys($module_list), SORT_DESC, $module_list); + $this->sortUninstalledExtensions($module_list); $uninstall = array_intersect(array_keys($module_list), $uninstall); - // Sort the module list by their weights (reverse). So that dependencies - // are installed first. Modules of the same weight are sorted in - // alphabetical order. - array_multisort(array_values($module_list), SORT_DESC, array_keys($module_list), SORT_ASC, $module_list); + $this->sortInstalledExtensions($module_list); $install = array_intersect(array_keys($module_list), $install); // Work out what themes to enable and to disable.