| 5 install.php | hook_uninstall() |
| 6 install.php | hook_uninstall() |
| 7 system.api.php | hook_uninstall() |
| 8 system.api.php | hook_uninstall() |
Remove any information that the module sets.
The information that the module should remove includes:
- variables that the module has set using variable_set() or system_settings_form()
- modifications to existing tables
The module should not remove its entry from the {system} table. Database tables defined by hook_schema() will be removed automatically.
The uninstall hook must be implemented in the module's .install file. It will fire when the module gets uninstalled but before the module's database tables are removed, allowing your module to query its own tables during this routine.
When hook_uninstall() is called, your module will already be disabled, so its .module file will not be automatically included. If you need to call API functions from your .module file in this hook, use drupal_load() to make them available. (Keep this usage to a minimum, though, especially when calling API functions that invoke hooks, or API functions from modules listed as dependencies, since these may not be available or work as expected when the module is disabled.)
See also
Related topics
File
- modules/
system/ system.api.php, line 3419 - Hooks provided by Drupal core and the System module.
Code
<?php
function hook_uninstall() {
variable_del('upload_file_types');
}
?> Login or register to post comments
Comments
Do not use API functions supplied by .module files
The code inside a
hook_uninstall()implementation should not call any API functions that are provided by any.modulefile, including its own, unless:drupal_load().See also:
Common Knowledge
This is sort of assumed knowledge but, like hook_install and hook_update_N, this function should live in a .install file.