I have inherited a Drupal 7 site, and it is running quite slowly.

After enabling the Devel Query output, I noticed (not that it would be hard or anything) that there is a 65ms query DELETE FROM menu_router. There are also roughly 25 other queries, all coming from the _menu_router_save() function.

It seems to me that the Menu Router is being rebuilt on every single page request... Currently, our themer is rebuilding the theme registry on every build -- but that should be drupal_theme_rebuild(), correct? I don't see anything on that function's page that would indicate it also rebuilds the menu router..

Additionally, I recently installed a custom module, and hook_theme would never actually take -- I tried clearing the cache and rebuilding the menu router, but I ended up having to add the values manually to the menu_router table. This makes me wonder if the menu_router table is even being truncated during this ~65ms query.

Does anyone know why my Drupal 7 site would be trying to do this?

  • 1
    That's definitely non-standard, the easiest thing to do would be to get XDebug installed, stick a breakpoint in _menu_router_save() and check the stack trace to see where it's coming from – Clive Sep 24 '13 at 17:04
  • I've tracked it back to variable_get('menu_rebuild_needed') always returning TRUE! Why would this be? – tigertrussell Sep 24 '13 at 19:30
  • Check sites/default/settings.php for $conf['menu_rebuild_needed'], it might be overridden in there – Clive Sep 24 '13 at 19:40
  • It wasn't overridden - more debugging has revealed that there is a PDOException thrown every time it tries to rebuild the menu. It catches the exception, rolls back the SQL changes, and never sets the menu_rebuild_needed to false, because it still needs a rebuild. The PDOException is an "Integrity Constraint" stating that the title field of this query cannot be null. I am currently combing through a HUGE array that it spit out in the error log to see exactly what URL has a null title in its hook_menu and hopefully that will solve the issue. – tigertrussell Sep 24 '13 at 19:48
  • The paths that were causing this were: admin/appearance/settings/hooks, ctools/context/ajax/add, ctools/context/ajax/delete, ctools/context/ajax/configure – tigertrussell Sep 24 '13 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.