menu_rebuild

  1. drupal
    1. 5
    2. 6
    3. 7
    4. 8
Versions
5 – 8 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

▾ 22 functions call menu_rebuild()

DrupalWebTestCase::drupalCreateContentType in modules/simpletest/drupal_web_test_case.php
Creates a custom content type based on default settings.
drupal_flush_all_caches in includes/common.inc
Flush all cached data on the site.
example_profile_tasks in documentation/developer/example.profile
Perform any final installation tasks for this profile.
FieldExampleTest::testExampleFieldBasic in examples/field_example/field_example.test
Test basic functionality of the example field.
field_ui_field_attach_rename_bundle in modules/field_ui/field_ui.module
Implements hook_field_attach_rename_bundle().
install_configure_form in includes/install.core.inc
Installation task; configure settings for the new site.
MenuRouterTestCase::testMenuName in modules/simpletest/tests/menu.test
Tests for menu_name parameter for hook_menu().
menu_enable in modules/menu/menu.module
Implements hook_enable().
menu_get_item in includes/menu.inc
Get a router item.
menu_uninstall in modules/menu/menu.install
Implements 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
Form submission handler for node_type_form().
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.
SearchKeywordsConditions::setUp in modules/search/search.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
SearchPageOverride::setUp in modules/search/search.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
shortcut_install in modules/shortcut/shortcut.install
Implements hook_install().
standard_install in profiles/standard/standard.install
Implements hook_install().
system_theme_default in modules/system/system.admin.inc
Menu callback; Set the default theme.
theme_disable in includes/theme.inc
Disable a given list of themes.
theme_enable in includes/theme.inc
Enable a given list of themes.
_locale_import_po in includes/locale.inc
Parses Gettext Portable Object file information and inserts into database

Code

includes/menu.inc, line 2643

<?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;
  }

  $transaction = db_transaction();

  try {
    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');
    }
  }
  catch (Exception $e) {
    $transaction->rollback();
    watchdog_exception('menu', $e);
  }

  lock_release('menu_rebuild');
  return TRUE;
}
?>