1 install.inc backdrop_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE)

Uninstalls a given list of disabled modules.


array $module_list: The modules to uninstall. It is the caller's responsibility to ensure that all modules in this list have already been disabled before this function is called.

bool $uninstall_dependents: (optional)

  • If TRUE, dependency-checking is enabled. This means that any modules dependent on the passed-in module(s) are checked to see if they're already uninstalled, or if they're included in $module_list. If all dependents are in $module_list, they will all be uninstalled in the correct order. If, however, dependent modules are still installed and not included in $module_list, the passed-in module(s) will not be uninstalled. Note that dependency-checking incurs a significant performance cost.
  • If FALSE, dependency-checking is bypassed. Dependent modules not included in $module_list will not be uninstalled, and modules in the list may not be uninstalled in the correct order. This could lead to problems, and so should only be used if you know $module_list is already complete and in the correct order.

Return value

bool: Returns FALSE if $uninstall_dependents is TRUE, and one or more dependent modules are still installed but not included in $module_list. Otherwise returns TRUE.

See also




core/includes/install.inc, line 1020
API functions for installing modules and themes.


function backdrop_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) {
  if ($uninstall_dependents) {
    // Get all module data so we can find dependents and sort.
    $module_data = system_rebuild_module_data();
    // Create an associative array with weights as values.
    $module_list = array_flip(array_values($module_list));

    $profile = backdrop_get_profile();
    foreach (array_keys($module_list) as $module) {
      if (!isset($module_data[$module]) || backdrop_get_installed_schema_version($module) == SCHEMA_UNINSTALLED) {
        // This module doesn't exist or is already uninstalled. Skip it.
      $module_list[$module] = $module_data[$module]->sort;

      // If the module has any dependents which are not already uninstalled and
      // not included in the passed-in list, abort. It is not safe to uninstall
      // them automatically because uninstalling a module is a destructive
      // operation.
      foreach (array_keys($module_data[$module]->required_by) as $dependent) {
        if (!isset($module_list[$dependent]) && backdrop_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED && $dependent != $profile) {
          return FALSE;

    // Sort the module list by pre-calculated weights.
    $module_list = array_keys($module_list);

  foreach ($module_list as $module) {
    // Uninstall the module.
    module_invoke($module, 'uninstall');

    watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
    backdrop_set_installed_schema_version($module, SCHEMA_UNINSTALLED);

  if (!empty($module_list)) {
    // Let other modules react.
    module_invoke_all('modules_uninstalled', $module_list);

  return TRUE;