8.5.x module.api.php hook_uninstall()
8.0.x module.api.php hook_uninstall()
8.1.x module.api.php hook_uninstall()
8.2.x module.api.php hook_uninstall()
8.3.x module.api.php hook_uninstall()
8.4.x module.api.php hook_uninstall()
8.6.x module.api.php hook_uninstall()
5.x install.php hook_uninstall()
6.x install.php hook_uninstall()
7.x system.api.php hook_uninstall()

Remove any information that the module sets.

The information that the module should remove includes:

  • state that the module has set using \Drupal::state()
  • modifications to existing tables

The module should not remove its entry from the module configuration. 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.

See also




Related topics

13 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.

book_uninstall in core/modules/book/book.install
Implements hook_uninstall().
comment_uninstall in core/modules/comment/comment.install
Implements hook_uninstall().
forum_uninstall in core/modules/forum/forum.install
Implements hook_uninstall().
image_uninstall in core/modules/image/image.install
Implements hook_uninstall().
locale_test_uninstall in core/modules/locale/tests/modules/locale_test/locale_test.install
Implements hook_uninstall().

... See full list


core/lib/Drupal/Core/Extension/module.api.php, line 288
Hooks related to module and update systems.


function hook_uninstall() {

  // Remove the styles directory and generated images.
  file_unmanaged_delete_recursive(file_default_scheme() . '://styles');