Jump to:
| Project: | Drupal core |
| Version: | 7.0 |
| Component: | install system |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I'm in the midst of developing a custom module for a client and I've gone ahead and created an .install file with 2 functions: a hook_install and a hook_uninstall.
The hook_install function works like a champ, but I don't think the hook_uninstall function is ever being called. Here's how I've tested it:
1. installed the module - verified that the tables were correctly created in the DB
2. uninstalled the module from admin/build/modules - the DB tables were not dropped.
3. I added an "echo" and an "exit" to the hook_uninstall to see if it was even being called during uninstall and it wasn't.
Here's my hook_uninstall as it stands right now:
function newmodule_uninstall() {
echo "hello";
exit;
db_query('DROP TABLE {newmodule}');
//drupal_set_message(t('new module tables removed.'));
}Any ideas? Is this a bug or am I doing something incorrect?
Thanks,
-mike
Comments
#1
I had tested on my computer, it is really called!
#2
No bug detected.
I´ve tested your code and no problems occurred.
"hello" was displayed.
After removing echo and exit, table was removed from Database (as expected).
You might consider a silly suggestion, but I advise you to make sure the name of .install file matches the name of your uninstall function.
Moving this to support request, once no bug was detected.
If you think other way, fell free to re-direct the topic.
#3
#4
You do visit http://www.example.com/admin/build/modules/uninstall too right? Because if you don't you only disable the module and you don't uninstall it.
Judging from the age of this issue I'm going to assume that you solved this already.
If not feel free to reopen.
- Arie
#5
Automatically closed -- issue fixed for two weeks with no activity.
#6
Quick note -- looks like if another module depends on the module you are trying to uninstall, hook_uninstall() won't be called. Uninstalling the dependant module made hook_install() work in the dependency.
#7
ainigma32, that was like a blessing beam of light to me :) Sometimes things are not so certain.