By user12804


2013-01-28 06:06:25 8 Comments

I would like to call the menu_rebuild() function, but I am not sure of where exactly paste the code snippet.

I can't find the update.php file anywhere in my local instance.

The reason I would like to attempt this is that I deleted all the nodes, but they are still appearing under the menu structure.

7 comments

@kenorb 2014-07-24 12:20:49

Drupal 7

If you're using drush, you may run:

drush eval 'menu_rebuild();'

If won't work, see: How to do menu rebuild when having PHP Fatal error?

Drupal 6

drush php-eval 'drupal_rebuild_theme_registry()'

memcached

If you're using memcached, you've to restart it.

On Linux: /etc/init.d/memcached restart

On OS X (if using Homebrew): brew services restart memcached

@nilsun 2014-11-17 20:56:18

vote up for the correct drush commands to do that easely, but you definitely should add that in some cases you need to empty the corresponding database tables before like mentioned by @Valk above

@Michal Przybylowicz 2015-06-15 17:27:42

Alternative way is to set variable:

variable_set('menu_rebuild_needed', TRUE);

This will trigger the menu_rebuild();

@user28323 2014-04-20 12:18:25

To fix the admin menu use in SQL and note that as Valk stated above it will remove all customization from your administration management menu. After you run it clear your cache adn the management menu will be rebuilt to its default settings.

Here is the SQL query:

DELETE FROM menu_links WHERE menu_name='management' 

@nilsun 2014-11-17 20:59:34

to rebuild menu mostly becomes needed when something is really broken and Drupal can'T fix it in the middle. That'S why I would rather recommend Valks method because a complete reset is a better answer for such question if no more details are provided WHAT is broken.

@Valk 2013-08-12 06:23:13

Open the database schema, then delete all contents of menu_links and menu_router tables with the following SQL queries:

DELETE FROM menu_links;
DELETE FROM menu_router;

Then run http://example.com/update.php. It will call menu_rebuild(), which will populate these tables with 'fresh' data. It worked for me after a "PHP Fatal Error: Out of memory" turned some of my menus into a mess.

But be aware, that it will wipe out all you custom menus which you will have to rebuild manually. To avoid it you may play a bit with deleting of some selected records from menu_router and menu_links, but for me it didn't work well.

And don't forget to back-up your database and site directory before deleting contents from the tables.

@nilsun 2014-11-17 20:57:27

vote up for the needed additional info, that sometimes you DEFINITELY need to empty the correspnding database tables before menu_rebuild. THis is confirmed here from long term experiences ...

@Sithu 2013-01-28 08:13:00

Create a file with the following content and simply drop in the Drupal root directory. Let's say menu-rebuild.php. Run it http://example.com/menu-rebuild.php

<?php
error_reporting(E_ALL);
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

menu_rebuild();

@David Thomas 2013-01-28 06:21:12

A couple of different ways:

  1. Call menu_rebuild() from hook_update_N
  2. Edit and save a menu settings form from Drupal admin.
  3. From the command line, with drush: drush cc menu

@user12804 2013-01-28 06:28:10

Thank you. Can I do this without drush as well?

@David Thomas 2013-01-28 06:33:32

Yes, any of the above 3 methods will work by itself.

@user12804 2013-01-28 07:47:23

Re: Edit and save a menu link from Drupal admin. Doesn't work, already tried that a few times...

@David Thomas 2013-01-28 07:52:25

Yes, that one was meant for the menu settings page. You can also call menu_cache_clear_all() to rebuild menu cache

@penten 2013-01-28 06:16:43

Going to admin/config/development/performance and clicking on the "Clear all caches" button will cause the menu to be rebuilt, as well as clear template, block, page, etc. cache.

@user12804 2013-01-28 06:27:47

Thanks Penten, I tried that a number of times, but no luck. The deleted nodes are still appearing in the Navigation menu structure :(

Related Questions

Sponsored Content

1 Answered Questions

How do I dynamically change the title of a menu link?

  • 2015-02-14 18:52:32
  • Jason
  • 708 View
  • 0 Score
  • 1 Answer
  • Tags:   routes

6 Answered Questions

[SOLVED] Why does menu items start disappearing

  • 2011-06-28 08:27:45
  • Christoffer Björkskog
  • 8169 View
  • 4 Score
  • 6 Answer
  • Tags:   7 routes caching

2 Answered Questions

[SOLVED] Views templates deleted when core updated

  • 2015-05-08 14:31:31
  • NewSites
  • 45 View
  • 1 Score
  • 2 Answer
  • Tags:   views updating

6 Answered Questions

[SOLVED] How to output child links based on the current page

  • 2012-07-24 20:27:40
  • Chris Rockwell
  • 10765 View
  • 10 Score
  • 6 Answer
  • Tags:   routes

1 Answered Questions

Calling menu in a certain way from page.tpl.php

  • 2014-03-20 22:12:24
  • Jane
  • 105 View
  • 0 Score
  • 1 Answer
  • Tags:   routes theming

0 Answered Questions

Drupal failed after update

  • 2014-01-24 12:11:27
  • mszostek
  • 1001 View
  • 1 Score
  • 0 Answer
  • Tags:   7 updating

2 Answered Questions

[SOLVED] How to display tabbed menu, created via hook_menu?

  • 2014-01-15 08:01:58
  • bolden kintaro
  • 337 View
  • 1 Score
  • 2 Answer
  • Tags:   routes

2 Answered Questions

[SOLVED] Identifying the level of menu items in the item array?

  • 2012-03-01 21:11:33
  • Ashlar
  • 243 View
  • 1 Score
  • 2 Answer
  • Tags:   routes

1 Answered Questions

[SOLVED] Allow anonymous users to custom menus

1 Answered Questions

[SOLVED] How to add additional tabs to user profiles

  • 2012-05-15 08:00:43
  • Mike
  • 4250 View
  • 1 Score
  • 1 Answer
  • Tags:   7 routes users

Sponsored Content