4.6.x menu.inc menu_rebuild()
4.7.x menu.inc menu_rebuild()
5.x menu.inc menu_rebuild()
6.x menu.inc menu_rebuild()
7.x menu.inc menu_rebuild()

(Re)populate the database tables used by various menu functions.

This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the maintenance page environment is different and leaves stale data in the menu tables.

Related topics

15 calls to menu_rebuild()
default_profile_tasks in profiles/default/default.profile
Perform any final installation tasks for this profile.
drupal_flush_all_caches in includes/common.inc
Flush all cached data on the site.
example_profile_tasks in developer/example.profile
Perform any final installation tasks for this profile.
install_tasks in ./install.php
Tasks performed after the database is initialized.
menu_enable in modules/menu/menu.module
Implementation of hook_enable()

... See full list


includes/menu.inc, line 1695
API for the Drupal menu system.


function menu_rebuild() {
  if (!lock_acquire('menu_rebuild')) {

    // Wait for another request that is already doing this work.
    // We choose to block here since otherwise the router item may not
    // be avaiable in menu_execute_active_handler() resulting in a 404.
    return FALSE;
  $menu = menu_router_build(TRUE);

  // Clear the menu, page and block caches.
  if (defined('MAINTENANCE_MODE')) {
    variable_set('menu_rebuild_needed', TRUE);
  else {
  return TRUE;