diff --git includes/install.inc includes/install.inc index 68a67bc..c9d9266 100644 --- includes/install.inc +++ includes/install.inc @@ -548,7 +548,7 @@ abstract class DatabaseTasks { * * @param $database * An array of driver specific configuration options. - * + * * @return * An array of driver configuration errors, keyed by form element name. */ @@ -783,48 +783,30 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents } foreach ($module_list as $module) { - // First, retrieve all the module's menu paths from db. - drupal_load('module', $module); - $paths = module_invoke($module, 'menu'); - // Uninstall the module. module_load_install($module); module_invoke($module, 'uninstall'); drupal_uninstall_schema($module); watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO); - - // Now remove the menu links for all paths declared by this module. - if (!empty($paths)) { - $paths = array_keys($paths); - // Clean out the names of load functions. - foreach ($paths as $index => $path) { - $parts = explode('/', $path, MENU_MAX_PARTS); - foreach ($parts as $k => $part) { - if (preg_match('/^%[a-z_]*$/', $part)) { - $parts[$k] = '%'; - } - } - $paths[$index] = implode('/', $parts); - } - - $result = db_select('menu_links') - ->fields('menu_links') - ->condition('router_path', $paths, 'IN') - ->condition('external', 0) - ->orderBy('depth') - ->execute(); - // Remove all such items. Starting from those with the greatest depth will - // minimize the amount of re-parenting done by menu_link_delete(). - foreach ($result as $item) { - _menu_delete_item($item, TRUE); - } - } - drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED); } if (!empty($module_list)) { + // Clean up menu links pointing to paths provided by uninstalled modules. + $query = db_select('menu_links', 'l') + ->fields('l') + ->condition('external', 0) + ->orderBy('depth'); + $query->leftJoin('menu_router', 'r', 'l.router_path = r.path'); + $query->isNull('r.path'); + + // Remove all such items. Starting from those with the greatest depth will + // minimize the amount of re-parenting done by menu_link_delete(). + foreach ($query->execute() as $item) { + _menu_delete_item($item, TRUE); + } + // Call hook_module_uninstall to let other modules act module_invoke_all('modules_uninstalled', $module_list); }