function hook_uninstall
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
- 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
- 10 core/lib/Drupal/Core/Extension/module.api.php \hook_uninstall()
- 11.x core/lib/Drupal/Core/Extension/module.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
22 functions implement hook_uninstall()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- aggregator_uninstall in modules/
aggregator/ aggregator.install - Implements hook_uninstall().
- blog_uninstall in modules/
blog/ blog.install - Implements hook_uninstall().
- book_uninstall in modules/
book/ book.install - Implements hook_uninstall().
- comment_uninstall in modules/
comment/ comment.install - Implements hook_uninstall().
- contact_uninstall in modules/
contact/ contact.install - Implements hook_uninstall().
1 invocation of hook_uninstall()
- drupal_uninstall_modules in includes/
install.inc - Uninstalls a given list of disabled modules.
File
-
modules/
system/ system.api.php, line 3641
Code
function hook_uninstall() {
variable_del('upload_file_types');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.