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.


@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()'


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 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

define('DRUPAL_ROOT', getcwd());
require_once './includes/';


@mbomb007 2019-09-23 14:43:24

It may be easier to run this using Devel

@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

Limit menu items available as possible parents on node creation

  • 2013-02-01 14:27:08
  • Marcus Farrington
  • 416 View
  • 3 Score
  • 1 Answer
  • Tags:   7 routes

1 Answered Questions

[SOLVED] Setting a View's Menu Item to a Sub-Menu

  • 2012-01-31 23:52:30
  • Godwin
  • 1576 View
  • 3 Score
  • 1 Answer
  • Tags:   7 views routes

6 Answered Questions

[SOLVED] Why does menu items start disappearing

  • 2011-06-28 08:27:45
  • Christoffer Björkskog
  • 8303 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
  • 50 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
  • 11110 View
  • 10 Score
  • 6 Answer
  • Tags:   routes

1 Answered Questions

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

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

1 Answered Questions

[SOLVED] Some menus not showing in Menu Settings drop down when editing page

  • 2012-07-27 22:35:51
  • Justin
  • 2046 View
  • 2 Score
  • 1 Answer
  • Tags:   routes

1 Answered Questions

add first/last classes when using theme_menu_link

  • 2013-01-28 14:36:20
  • petergus
  • 251 View
  • 0 Score
  • 1 Answer
  • Tags:   routes

3 Answered Questions

[SOLVED] Displaying node reference select list as ordered menu list

  • 2012-01-12 15:52:54
  • Garry
  • 1264 View
  • 5 Score
  • 3 Answer
  • Tags:   views routes nodes

1 Answered Questions

[SOLVED] How to add additional tabs to user profiles

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

Sponsored Content