Skip to content

Instantly share code, notes, and snippets.

@daggerhart
Created August 16, 2014 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daggerhart/1eacf11d84c9e823523e to your computer and use it in GitHub Desktop.
Save daggerhart/1eacf11d84c9e823523e to your computer and use it in GitHub Desktop.
Drupal 7 force uninstall of disabled modules.
<?php
// get disabled modules, skip 'test' modules
$modules = db_query("SELECT `name` FROM {system} WHERE TYPE = 'module' AND `status` = 0 AND `name` NOT LIKE '%test%' ORDER BY `name` DESC")->fetchCol();
// ensure disabled
module_disable($modules);
// force uninstall
foreach ($modules as $module) {
// 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);
drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment