menu_rebuild

Versions
4.6 – 7
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.

Return value

TRUE if the menu was rebuilt, FALSE if another thread was rebuilding in parallel and the current thread just waited for completion.

Related topics

▾ 16 functions call menu_rebuild()

default_install in profiles/default/default.install
Implement hook_install().
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_configure_form in ./install.php
Installation task; configure settings for the new site.
menu_enable in modules/menu/menu.module
Implement hook_enable().
menu_execute_active_handler in includes/menu.inc
Execute the page callback associated with the current path.
menu_uninstall in modules/menu/menu.install
Implement hook_uninstall().
node_type_delete_confirm_submit in modules/node/content_types.inc
Process content type delete confirm submissions.
node_type_form_submit in modules/node/content_types.inc
Implement hook_form_submit().
profile_admin_overview_submit in modules/profile/profile.admin.inc
Submit handler to update changed profile field weights and categories.
profile_field_form_submit in modules/profile/profile.admin.inc
Process profile_field_form submissions.
system_modules_submit in modules/system/system.admin.inc
Submit callback; handles modules form submission.
system_themes_form_submit in modules/system/system.admin.inc
Process system_themes_form form submissions.
toolbar_install in modules/toolbar/toolbar.install
Implementation of hook_install().
update_uninstall in modules/update/update.install
Implement hook_uninstall().
_locale_import_po in includes/locale.inc
Parses Gettext Portable Object file information and inserts into database

Code

includes/menu.inc, line 2211

<?php
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 available in menu_execute_active_handler() resulting in a 404.
    lock_wait('menu_rebuild');
    return FALSE;
  }

  list($menu, $masks) = menu_router_build();
  _menu_router_save($menu, $masks);
  _menu_navigation_links_rebuild($menu);
  // Clear the menu, page and block caches.
  menu_cache_clear_all();
  _menu_clear_page_cache();

  if (defined('MAINTENANCE_MODE')) {
    variable_set('menu_rebuild_needed', TRUE);
  }
  else {
    variable_del('menu_rebuild_needed');
  }
  lock_release('menu_rebuild');
  return TRUE;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.