function hook_rebuild

Rebuild data based upon refreshed caches.

This hook allows your module to rebuild its data based on the latest/current module data. It runs after hook_cache_flush() and after all module data has been updated.

This hook is only invoked after the system has been completely cleared; i.e., all previously cached data is known to be gone and every API in the system is known to return current information, so your module can safely rely on all available data to rebuild its own.

The menu router is the only exception regarding rebuilt data; it is only rebuilt after all hook_rebuild() implementations have been invoked. That ensures that hook_menu() implementations and the final router rebuild can rely on all data being returned by all modules.

See also

hook_cache_flush()

drupal_flush_all_caches()

Related topics

9 functions implement hook_rebuild()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_rebuild in drupal/core/modules/block/block.module
Implements hook_rebuild().
drupal_theme_rebuild in drupal/core/includes/theme.inc
Forces the system to rebuild the theme registry.
field_rebuild in drupal/core/modules/field/field.module
Implements hook_rebuild().
form_test_user_register_form_rebuild in drupal/core/modules/system/tests/modules/form_test/form_test.module
Submit callback that just lets the form rebuild.
menu_router_rebuild in drupal/core/includes/menu.inc
Populates the database tables used by various menu functions.

... See full list

1 invocation of hook_rebuild()
drupal_flush_all_caches in drupal/core/includes/common.inc
Flushes all persistent caches, resets all variables, and rebuilds all data structures.

File

drupal/core/modules/system/system.api.php, line 1975
Hooks provided by Drupal core and the System module.

Code

function hook_rebuild() {
  $themes = list_themes();
  foreach ($themes as $theme) {
    _block_rehash($theme->name);
  }
}