User login

Rebuild menu cache to force recognition of menus added while developing a module

Rebuild menus so that menu items and callbacks defined through the menu system take effect while you are developing a module.

Resolution

The quick fix:
menu_rebuild

I know I posted about this before, and it took me five minutes to find.

Anyhow, this is useful during development to clear and rebuild the menu cache, so that your menus added to a module (hook_menu) actually will show up for you, without reinstalling the module or something stupid.

Then immediately remove your call to menu_rebuild!

Actually I got a 500 Internal server error. But it worked.

Searched words: 
reindex menus refresh menus menu show up drupal regenerate menus remake menu items Drupal

Comments

This would seem to be a bad

This would seem to be a bad way. Recommend you use the devel module, which gives you a link to clear menu cache.

Do NOT use the reset menus link though! That undoes all your custamizations.

Very interesting, i like

Very interesting, i like this website.

dldege: btw, what is the

dldege: btw, what is the easiest way to force a menu_rebuild in 6
[1:15pm] dldege: truncating the menu_router table doesn't work to well
[1:19pm] chx: add menu_rebuild to index.php
[1:19pm] chx: just before the menu_execute_active_handler

This is a popular question,

This is a popular question, and I feel the answer is not satisfactory yet:

On IRC:

hanumani: How do I clear the menu cache in drupal 6? I created a new module, but it's not even calling mymod_menu in fact, I looked in menu.inc and menu_rebuild never gets run What happened to TRUNCATE cache_menu and $may_cache? Is there a doc on this change somewhere?

Placinta joined the chat room. (This is just 1 min later!)

Placinta: Where should I place menu_rebuild(), so that I don't have to refresh 2 times the page, in order to see the changes?

I gave chx answer here.

hanumani said there wasn't a link in devel on 6 (all still in beta though).

Which version?

Which version are you talking about?

Drupal 6

.

Your solution does not work

Your solution does not work in all circumstances, for instance I clobbered the menu cache whilst I was manually uninstalling a module in development. I was locked out with a white screen until I tried

?q=admin/build/modules

That rebuilds and everything is ok.

You just saved my life. I was

You just saved my life. I was a newbie to Drupal and my installation crashed dawn once I installed a module, cause of a f*** max_memory_usage exception.
The result was that I could not access to some menus in my administration page... Then I put that function call in my theme file and it rebuilded routes and stuff to make it work like it was working before! Thank you!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.