From 34ec8f9834579098308308c85be484fe5b771995 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Wed, 8 Oct 2008 01:42:16 +0000
Subject: [PATCH] #261148 by chx and pwolanin: Allow recovery from a failed
 menu build.

---
 includes/menu.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/includes/menu.inc b/includes/menu.inc
index 312812aa06b0..a92481634f2e 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -387,7 +387,9 @@ function menu_execute_active_handler($path = NULL) {
   if (_menu_site_is_offline()) {
     return MENU_SITE_OFFLINE;
   }
-  if (variable_get('menu_rebuild_needed', FALSE)) {
+  // Rebuild if we know it's needed, or if the menu masks are missing which
+  // occurs rarely, likely due to a race condition of multiple rebuilds.
+  if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
     menu_rebuild();
   }
   if ($router_item = menu_get_item($path)) {
-- 
GitLab