Commit 65b155d9 authored by Dries's avatar Dries

Issue #1199946 by alexpott, fubhy, bojanz, steinmb, chx, catch: Fixed Disabled...

Issue #1199946 by alexpott, fubhy, bojanz, steinmb, chx, catch: Fixed Disabled modules are broken beyond repair so the 'disable' functionality needs to be removed.
parent 6b7bdcdd
...@@ -86,8 +86,10 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N ...@@ -86,8 +86,10 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N
// Notify the entity storage controller. // Notify the entity storage controller.
$method = 'onBundle' . ucfirst($hook); $method = 'onBundle' . ucfirst($hook);
\Drupal::entityManager()->getStorageController($entity_type)->$method($bundle, $bundle_new); $storage_controller = \Drupal::entityManager()->getStorageController($entity_type);
if (method_exists($storage_controller, $method)) {
$storage_controller->$method($bundle, $bundle_new);
}
// Invoke hook_entity_bundle_*() hooks. // Invoke hook_entity_bundle_*() hooks.
\Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new)); \Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new));
} }
......
...@@ -995,7 +995,7 @@ function install_base_system(&$install_state) { ...@@ -995,7 +995,7 @@ function install_base_system(&$install_state) {
// Enable the user module so that sessions can be recorded during the // Enable the user module so that sessions can be recorded during the
// upcoming bootstrap step. // upcoming bootstrap step.
module_enable(array('user'), FALSE); Drupal::moduleHandler()->install(array('user'), FALSE);
// Save the list of other modules to install for the upcoming tasks. // Save the list of other modules to install for the upcoming tasks.
// variable_set() can be used now that system.module is installed. // variable_set() can be used now that system.module is installed.
...@@ -2037,7 +2037,7 @@ function _install_module_batch($module, $module_name, &$context) { ...@@ -2037,7 +2037,7 @@ function _install_module_batch($module, $module_name, &$context) {
// loaded by drupal_bootstrap in subsequent batch requests, and other // loaded by drupal_bootstrap in subsequent batch requests, and other
// modules possibly depending on it can safely perform their installation // modules possibly depending on it can safely perform their installation
// steps. // steps.
module_enable(array($module), FALSE); Drupal::moduleHandler()->install(array($module), FALSE);
$context['results'][] = $module; $context['results'][] = $module;
$context['message'] = t('Installed %module module.', array('%module' => $module_name)); $context['message'] = t('Installed %module module.', array('%module' => $module_name));
} }
...@@ -2529,7 +2529,7 @@ function install_configure_form_submit($form, &$form_state) { ...@@ -2529,7 +2529,7 @@ function install_configure_form_submit($form, &$form_state) {
// Enable update.module if this option was selected. // Enable update.module if this option was selected.
if ($form_state['values']['update_status_module'][1]) { if ($form_state['values']['update_status_module'][1]) {
module_enable(array('file', 'update'), FALSE); Drupal::moduleHandler()->install(array('file', 'update'), FALSE);
// Add the site maintenance account's email address to the list of // Add the site maintenance account's email address to the list of
// addresses to be notified when updates are available, if selected. // addresses to be notified when updates are available, if selected.
......
...@@ -203,8 +203,9 @@ function language_types_disable($types) { ...@@ -203,8 +203,9 @@ function language_types_disable($types) {
*/ */
function language_types_set(array $configurable_language_types) { function language_types_set(array $configurable_language_types) {
// Ensure that we are getting the defined language negotiation information. An // Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached // invocation of \Drupal\Core\Extension\ModuleHandler::install() or
// information. // \Drupal\Core\Extension\ModuleHandler::uninstall() could invalidate the
// cached information.
drupal_static_reset('language_types_info'); drupal_static_reset('language_types_info');
drupal_static_reset('language_negotiation_info'); drupal_static_reset('language_negotiation_info');
...@@ -343,8 +344,9 @@ function language_negotiation_get_switch_links($type, $path) { ...@@ -343,8 +344,9 @@ function language_negotiation_get_switch_links($type, $path) {
*/ */
function language_negotiation_purge() { function language_negotiation_purge() {
// Ensure that we are getting the defined language negotiation information. An // Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached // invocation of \Drupal\Core\Extension\ModuleHandler::install() or
// information. // \Drupal\Core\Extension\ModuleHandler::uninstall() could invalidate the
// cached information.
drupal_static_reset('language_negotiation_info'); drupal_static_reset('language_negotiation_info');
drupal_static_reset('language_types_info'); drupal_static_reset('language_types_info');
......
...@@ -201,32 +201,21 @@ function module_load_include($type, $module, $name = NULL) { ...@@ -201,32 +201,21 @@ function module_load_include($type, $module, $name = NULL) {
return FALSE; return FALSE;
} }
/**
* Enables or installs a given list of modules.
*
* @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->enable($module_list, $enable_dependencies = TRUE).
*/
function module_enable($module_list, $enable_dependencies = TRUE) {
return \Drupal::moduleHandler()->enable($module_list, $enable_dependencies);
}
/** /**
* Disables a given set of modules. * Installs a given list of modules.
* *
* @deprecated as of Drupal 8.0. Use * @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->disable($module_list, $disable_dependents = TRUE). * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE)
*/ */
function module_disable($module_list, $disable_dependents = TRUE) { function module_install($module_list, $enable_dependencies = TRUE) {
\Drupal::moduleHandler()->disable($module_list, $disable_dependents); return \Drupal::moduleHandler()->install($module_list, $enable_dependencies);
} }
/** /**
* Uninstalls a given list of disabled modules. * Installs a given list of modules.
* *
* @deprecated as of Drupal 8.0. Use * @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents = TRUE). * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE).
*/ */
function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) { function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) {
return \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents); return \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents);
...@@ -332,7 +321,7 @@ function module_set_weight($module, $weight) { ...@@ -332,7 +321,7 @@ function module_set_weight($module, $weight) {
->save(); ->save();
// Prepare the new module list, sorted by weight, including filenames. // Prepare the new module list, sorted by weight, including filenames.
// @see module_enable() // @see Drupal\Core\Extension\ModuleHandler::install()
$module_handler = \Drupal::moduleHandler(); $module_handler = \Drupal::moduleHandler();
$current_module_filenames = $module_handler->getModuleList(); $current_module_filenames = $module_handler->getModuleList();
$current_modules = array_fill_keys(array_keys($current_module_filenames), 0); $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
...@@ -345,13 +334,6 @@ function module_set_weight($module, $weight) { ...@@ -345,13 +334,6 @@ function module_set_weight($module, $weight) {
$module_handler->setModuleList($module_filenames); $module_handler->setModuleList($module_filenames);
return; return;
} }
$disabled_config = \Drupal::config('system.module.disabled');
if ($disabled_config->get($module) !== NULL) {
$disabled_config
->set($module, $weight)
->save();
return;
}
} }
/** /**
......
...@@ -335,7 +335,6 @@ function update_prepare_d8_bootstrap() { ...@@ -335,7 +335,6 @@ function update_prepare_d8_bootstrap() {
} }
$module_config = \Drupal::config('system.module'); $module_config = \Drupal::config('system.module');
$disabled_modules = \Drupal::config('system.module.disabled');
$theme_config = \Drupal::config('system.theme'); $theme_config = \Drupal::config('system.theme');
$disabled_themes = \Drupal::config('system.theme.disabled'); $disabled_themes = \Drupal::config('system.theme.disabled');
$schema_store = \Drupal::keyValue('system.schema'); $schema_store = \Drupal::keyValue('system.schema');
...@@ -378,9 +377,6 @@ function update_prepare_d8_bootstrap() { ...@@ -378,9 +377,6 @@ function update_prepare_d8_bootstrap() {
if ($record->status && isset($module_data[$record->name])) { if ($record->status && isset($module_data[$record->name])) {
$module_config->set('enabled.' . $record->name, $record->weight); $module_config->set('enabled.' . $record->name, $record->weight);
} }
else {
$disabled_modules->set($record->name, $record->weight);
}
} }
elseif ($record->type == 'theme') { elseif ($record->type == 'theme') {
if ($record->status) { if ($record->status) {
...@@ -399,7 +395,6 @@ function update_prepare_d8_bootstrap() { ...@@ -399,7 +395,6 @@ function update_prepare_d8_bootstrap() {
$sorted_with_filenames[$m] = drupal_get_filename('module', $m); $sorted_with_filenames[$m] = drupal_get_filename('module', $m);
} }
\Drupal::moduleHandler()->setModuleList($sorted_with_filenames); \Drupal::moduleHandler()->setModuleList($sorted_with_filenames);
$disabled_modules->save();
$theme_config->save(); $theme_config->save();
$disabled_themes->save(); $disabled_themes->save();
...@@ -490,8 +485,7 @@ function update_prepare_stored_includes() { ...@@ -490,8 +485,7 @@ function update_prepare_stored_includes() {
*/ */
function update_prepare_d8_language() { function update_prepare_d8_language() {
if (db_table_exists('languages')) { if (db_table_exists('languages')) {
Drupal::moduleHandler()->install(array('language'));
module_enable(array('language'));
$languages = db_select('languages', 'l') $languages = db_select('languages', 'l')
->fields('l') ->fields('l')
...@@ -683,7 +677,7 @@ function update_fix_d8_requirements() { ...@@ -683,7 +677,7 @@ function update_fix_d8_requirements() {
// Make sure that file.module is enabled as it is required for the user // Make sure that file.module is enabled as it is required for the user
// picture upgrade path. // picture upgrade path.
module_enable(array('file')); Drupal::moduleHandler()->install(array('file'));
$schema = array( $schema = array(
'description' => 'Generic key/value storage table with an expiration.', 'description' => 'Generic key/value storage table with an expiration.',
...@@ -727,8 +721,8 @@ function update_fix_d8_requirements() { ...@@ -727,8 +721,8 @@ function update_fix_d8_requirements() {
// views configurations. // views configurations.
// Like any other module APIs and services, Views' services are not available // Like any other module APIs and services, Views' services are not available
// in update.php. Existing listings are migrated into configuration, using // in update.php. Existing listings are migrated into configuration, using
// the limited standard tools of raw database queries and \Drupal::config(). // the limited standard tools of raw database queries and Drupal::config().
module_enable(array('views')); \Drupal::moduleHandler()->install(array('views'));
update_variable_set('update_d8_requirements', TRUE); update_variable_set('update_d8_requirements', TRUE);
} }
......
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Parser;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Class that manages enabled modules in a Drupal installation. * Class that manages modules in a Drupal installation.
*/ */
class ModuleHandler implements ModuleHandlerInterface { class ModuleHandler implements ModuleHandlerInterface {
...@@ -29,7 +28,7 @@ class ModuleHandler implements ModuleHandlerInterface { ...@@ -29,7 +28,7 @@ class ModuleHandler implements ModuleHandlerInterface {
protected $loadedFiles; protected $loadedFiles;
/** /**
* List of enabled modules. * List of installed modules.
* *
* @var array * @var array
* An associative array whose keys are the names of the modules and whose * An associative array whose keys are the names of the modules and whose
...@@ -69,7 +68,7 @@ class ModuleHandler implements ModuleHandlerInterface { ...@@ -69,7 +68,7 @@ class ModuleHandler implements ModuleHandlerInterface {
* Constructs a ModuleHandler object. * Constructs a ModuleHandler object.
* *
* @param array $module_list * @param array $module_list
* An associative array whose keys are the names of enabled modules and * An associative array whose keys are the names of installed modules and
* whose values are the module filenames. This is normally the * whose values are the module filenames. This is normally the
* %container.modules% parameter being set up by DrupalKernel. * %container.modules% parameter being set up by DrupalKernel.
* *
...@@ -502,79 +501,72 @@ public static function parseDependency($dependency) { ...@@ -502,79 +501,72 @@ public static function parseDependency($dependency) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function enable($module_list, $enable_dependencies = TRUE) { public function install(array $module_list, $enable_dependencies = TRUE) {
$module_config = \Drupal::config('system.module');
if ($enable_dependencies) { if ($enable_dependencies) {
// Get all module data so we can find dependencies and sort. // Get all module data so we can find dependencies and sort.
$module_data = system_rebuild_module_data(); $module_data = system_rebuild_module_data();
// Create an associative array with weights as values. $module_list = $module_list ? array_combine($module_list, $module_list) : array();
$module_list = array_flip(array_values($module_list)); if (array_diff_key($module_list, $module_data)) {
// One or more of the given modules doesn't exist.
return FALSE;
}
while (list($module) = each($module_list)) { // Only process currently uninstalled modules.
if (!isset($module_data[$module])) { $installed_modules = $module_config->get('enabled') ?: array();
// This module is not found in the filesystem, abort. if (!$module_list = array_diff_key($module_list, $installed_modules)) {
return FALSE; // Nothing to do. All modules already installed.
} return TRUE;
if ($module_data[$module]->status) { }
// Skip already enabled modules.
unset($module_list[$module]);
continue;
}
$module_list[$module] = $module_data[$module]->sort;
// Add dependencies to the list, with a placeholder weight. // Conditionally add the dependencies to the list of modules.
// The new modules will be processed as the while loop continues. if ($enable_dependencies) {
foreach (array_keys($module_data[$module]->requires) as $dependency) { // Add dependencies to the list. The new modules will be processed as the
if (!isset($module_list[$dependency])) { // while loop continues.
$module_list[$dependency] = 0; while (list($module) = each($module_list)) {
foreach (array_keys($module_data[$module]->requires) as $dependency) {
if (!isset($module_data[$dependency])) {
// The dependency does not exist.
return FALSE;
}
// Skip already installed modules.
if (!isset($module_list[$dependency]) && !isset($installed_modules[$dependency])) {
$module_list[$dependency] = $dependency;
}
} }
} }
} }
if (!$module_list) { // Set the actual module weights.
// Nothing to do. All modules already enabled. $module_list = array_map(function ($module) use ($module_data) {
return TRUE; return $module_data[$module]->sort;
} }, $module_list);
// Sort the module list by pre-calculated weights. // Sort the module list by their weights (reverse).
arsort($module_list); arsort($module_list);
$module_list = array_keys($module_list); $module_list = array_keys($module_list);
} }
foreach ($module_list as $module) {
// Throw an exception if the module name is too long.
if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array(
'%name' => $module,
'@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
)));
}
}
// Required for module installation checks. // Required for module installation checks.
include_once DRUPAL_ROOT . '/core/includes/install.inc'; include_once DRUPAL_ROOT . '/core/includes/install.inc';
$modules_installed = array(); $modules_installed = array();
$modules_enabled = array();
$module_config = \Drupal::config('system.module');
$disabled_config = \Drupal::config('system.module.disabled');
foreach ($module_list as $module) { foreach ($module_list as $module) {
// Only process modules that are not already enabled.
// A module is only enabled if it is configured as enabled. Custom or
// overridden module handlers might contain the module already, which means
// that it might be loaded, but not necessarily installed or enabled.
$enabled = $module_config->get("enabled.$module") !== NULL; $enabled = $module_config->get("enabled.$module") !== NULL;
if (!$enabled) { if (!$enabled) {
$weight = $disabled_config->get($module); // Throw an exception if the module name is too long.
if ($weight === NULL) { if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) {
$weight = 0; throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array(
'%name' => $module,
'@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
)));
} }
$module_config $module_config
->set("enabled.$module", $weight) ->set("enabled.$module", 0)
->set('enabled', module_config_sort($module_config->get('enabled'))) ->set('enabled', module_config_sort($module_config->get('enabled')))
->save(); ->save();
$disabled_config
->clear($module)
->save();
// Prepare the new module list, sorted by weight, including filenames. // Prepare the new module list, sorted by weight, including filenames.
// This list is used for both the ModuleHandler and DrupalKernel. It needs // This list is used for both the ModuleHandler and DrupalKernel. It needs
...@@ -591,12 +583,11 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -591,12 +583,11 @@ public function enable($module_list, $enable_dependencies = TRUE) {
$module_filenames = array(); $module_filenames = array();
foreach ($current_modules as $name => $weight) { foreach ($current_modules as $name => $weight) {
if (isset($current_module_filenames[$name])) { if (isset($current_module_filenames[$name])) {
$filename = $current_module_filenames[$name]; $module_filenames[$name] = $current_module_filenames[$name];
} }
else { else {
$filename = drupal_get_filename('module', $name); $module_filenames[$name] = drupal_get_filename('module', $name);
} }
$module_filenames[$name] = $filename;
} }
// Update the module handler in order to load the module's code. // Update the module handler in order to load the module's code.
...@@ -618,7 +609,7 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -618,7 +609,7 @@ public function enable($module_list, $enable_dependencies = TRUE) {
// taken over as %container.modules% parameter, which is passed to a fresh // taken over as %container.modules% parameter, which is passed to a fresh
// ModuleHandler instance upon first retrieval. // ModuleHandler instance upon first retrieval.
// @todo install_begin_request() creates a container without a kernel. // @todo install_begin_request() creates a container without a kernel.
if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { if ($kernel = \Drupal::service('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
$kernel->updateModules($module_filenames, $module_filenames); $kernel->updateModules($module_filenames, $module_filenames);
} }
...@@ -628,47 +619,37 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -628,47 +619,37 @@ public function enable($module_list, $enable_dependencies = TRUE) {
drupal_theme_rebuild(); drupal_theme_rebuild();
// Allow modules to react prior to the installation of a module. // Allow modules to react prior to the installation of a module.
$this->invokeAll('modules_preinstall', array(array($module))); $this->invokeAll('module_preinstall', array($module));
// Clear the entity info cache before importing new configuration. // Clear the entity info cache before importing new configuration.
entity_info_cache_clear(); entity_info_cache_clear();
// Now install the module if necessary. // Now install the module's schema if necessary.
if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) { drupal_install_schema($module);
drupal_install_schema($module);
// Set the schema version to the number of the last update provided // Set the schema version to the number of the last update provided
// by the module. // by the module.
$versions = drupal_get_schema_versions($module); $versions = drupal_get_schema_versions($module);
$version = $versions ? max($versions) : SCHEMA_INSTALLED; $version = $versions ? max($versions) : SCHEMA_INSTALLED;
// Install default configuration of the module. // Install default configuration of the module.
config_install_default_config('module', $module); config_install_default_config('module', $module);
// If the module has no current updates, but has some that were // If the module has no current updates, but has some that were
// previously removed, set the version to the value of // previously removed, set the version to the value of
// hook_update_last_removed(). // hook_update_last_removed().
if ($last_removed = $this->invoke($module, 'update_last_removed')) { if ($last_removed = $this->invoke($module, 'update_last_removed')) {
$version = max($version, $last_removed); $version = max($version, $last_removed);
}
drupal_set_installed_schema_version($module, $version);
// Allow the module to perform install tasks.
$this->invoke($module, 'install');
// Record the fact that it was installed.
$modules_installed[] = $module;
watchdog('system', '%module module installed.', array('%module' => $module), WATCHDOG_INFO);
} }
drupal_set_installed_schema_version($module, $version);
// Allow modules to react prior to the enabling of a module. // Record the fact that it was installed.
entity_info_cache_clear(); $modules_installed[] = $module;
$this->invokeAll('modules_preenable', array(array($module)));
// Enable the module.
$this->invoke($module, 'enable');
// Record the fact that it was enabled. // Allow the module to perform install tasks.
$modules_enabled[] = $module; $this->invoke($module, 'install');
watchdog('system', '%module module enabled.', array('%module' => $module), WATCHDOG_INFO); // Record the fact that it was installed.
watchdog('system', '%module module installed.', array('%module' => $module), WATCHDOG_INFO);
} }
} }
...@@ -677,195 +658,153 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -677,195 +658,153 @@ public function enable($module_list, $enable_dependencies = TRUE) {
$this->invokeAll('modules_installed', array($modules_installed)); $this->invokeAll('modules_installed', array($modules_installed));
} }
// If any modules were newly enabled, invoke hook_modules_enabled().
if (!empty($modules_enabled)) {
$this->invokeAll('modules_enabled', array($modules_enabled));
}
return TRUE; return TRUE;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
function disable($module_list, $disable_dependents = TRUE) { public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
if ($disable_dependents) { // Get all module data so we can find dependencies and sort.
// Get all module data so we can find dependents and sort. $module_data = system_rebuild_module_data();
$module_data = system_rebuild_module_data(); $module_list = $module_list ? array_combine($module_list, $module_list) : array();
// Create an associative array with weights as values. if (array_diff_key($module_list, $module_data)) {
$module_list = array_flip(array_values($module_list)); // One or more of the given modules doesn't exist.
return FALSE;
}
// Only process currently installed modules.
$module_config = \Drupal::config('system.module');
$installed_modules = $module_config->get('enabled') ?: array();
if (!$module_list = array_intersect_key($module_list, $installed_modules)) {
// Nothing to do. All modules already uninstalled.
return TRUE;
}
if ($uninstall_dependents) {
// Add dependent modules to the list. The new modules will be processed as
// the while loop continues.
$profile = drupal_get_profile(); $profile = drupal_get_profile();
while (list($module) = each($module_list)) { while (list($module) = each($module_list)) {
if (!isset($module_data[$module]) || !$module_data[$module]->status) { foreach (array_keys($module_data[$module]->required_by) as $dependent) {
// This module doesn't exist or is already disabled, skip it. if (!isset($module_data[$dependent])) {
unset($module_list[$module]); // The dependent module does not exist.
continue; return FALSE;
} }
$module_list[$module] = $module_data[$module]->sort;
// Add dependent modules to the list, with a placeholder weight. // Skip already uninstalled modules.
// The new modules will be processed as the while loop continues. if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
foreach ($module_data[$module]->required_by as $dependent => $dependent_data) { $module_list[$dependent] = TRUE;
if (!isset($module_list[$dependent]) && $dependent != $profile) {
$module_list[$dependent] = 0;
} }
} }
} }
// Sort the module list by pre-calculated weights.
asort($module_list);
$module_list = array_keys($module_list);
} }
$invoke_modules = array(); // Set the actual module weights.
$module_list = array_map(function ($module) use ($module_data) {
return $module_data[$module]->sort;
}, $module_list);
$module_config = \Drupal::config('system.module'); // Sort the module list by their weights.
$disabled_config = \Drupal::config('system.module.disabled'); asort($module_list);
$module_list = array_keys($module_list);
// Only process modules that are enabled. A module is only enabled if it is
// configured as enabled. Custom or overridden module handlers might contain
// the module already, which means that it might be loaded, but not
// necessarily installed.
$schema_store = \Drupal::keyValue('system.schema');
foreach ($module_list as $module) { foreach ($module_list as $module) {
// Only process modules that are enabled. // Allow modules to react prior to the uninstallation of a module.
// A module is only enabled if it is configured as enabled. Custom or $this->invokeAll('module_preuninstall', array($module));
// overridden module handlers might contain the module already, which means
// that it might be loaded, but not necessarily installed or enabled.
$enabled = $module_config->get("enabled.$module") !== NULL;
if ($enabled) {
module_load_install($module);
module_invoke($module, 'disable');
$disabled_config // Uninstall the module.
->set($module, $module_config->get($module)) module_load_install($module);
->save(); $this->invoke($module, 'uninstall');
$module_config drupal_uninstall_schema($module);
->clear("enabled.$module")