By marcusf on
Hello,
i wana disable/uninstall modules by another module for migrating a drupal site.
My code is the following one:
$delete_modules = array('news', 'poll');
foreach($delete_modules as $delete_modul ){
$result = db_query ( "SELECT name, filename, info FROM {system} WHERE type = 'module' and name IN( '%s' ) ORDER BY name", $delete_modul );
while ( $module = db_fetch_object ( $result ) ) {
$module_list [$module->name] = unserialize ( $module->info );
}
}
// Disable modules
module_disable ( array_keys ( $module_list ) );
// Uninstall modules
foreach ( $module_list as $module => $info) {
// Load the .install file, and check for an uninstall hook. If the hook exists, the module can be uninstalled.
module_load_install ( $module );
if (module_hook ( $module, 'uninstall' )) {
drupal_uninstall_module ( $module );
}
}
The function module_disable is called but the modules never be disabled.
I backtraced the standard module disable/uninstall form, but no solution till yet.
I wondered that in standard the module_disable() is called with all modules, not only with those, that I will be disabled....
Regards
Comments
Disable and Uninstall Module Programatically
Hi
You can disable module programatically by using module_disable ( array('module1','module2') );
you want to disable and uninstall the module Programatically by using this code: