Skip to content

Instantly share code, notes, and snippets.

@emsearcy
Created August 17, 2016 17:53
Show Gist options
  • Save emsearcy/0b411f209baffaa659a203eade80d607 to your computer and use it in GitHub Desktop.
Save emsearcy/0b411f209baffaa659a203eade80d607 to your computer and use it in GitHub Desktop.
No menu_rebuild recurse
diff --git a/includes/menu.inc b/includes/menu.inc
index ab97722..7181768 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -2767,7 +2767,14 @@ function menu_rebuild() {
// If we get here and menu_masks was not set, then it is possible a menu
// is being reloaded, or that the process rebuilding the menu was unable
// to complete successfully. A missing menu_masks variable could result
- // in a 404, so re-run the function.
+ // in a 404, so we cannot proceed without completing the rebuild.
+ if (variable_get('menu_rebuild_no_recurse')) {
+ // Sites with long menu_rebuild times or the ability to re-serve stale
+ // pages from external caches may want to fail early, rather than risk
+ // a cache stampede.
+ throw new Exception(t('Menu rebuild still in process or failing'));
+ }
+ // Re-run the function.
return menu_rebuild();
}
return FALSE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment