dev/core#2340 Skip rather than fail on bad menu item
authoreileen <emcnaughton@wikimedia.org>
Sat, 30 Jan 2021 01:11:29 +0000 (14:11 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 1 Feb 2021 21:04:24 +0000 (10:04 +1300)
CRM/Core/Menu.php

index 390d6a2a7c1b6e113c33836d49f3ca31d8917745..a25a8e39cbc6b8198cec5ec4886331cbdda04eb8 100644 (file)
@@ -265,14 +265,19 @@ class CRM_Core_Menu {
    */
   public static function build(&$menu) {
     foreach ($menu as $path => $menuItems) {
-      self::buildBreadcrumb($menu, $path);
-      self::fillMenuValues($menu, $path);
-      self::fillComponentIds($menu, $path);
-      self::buildReturnUrl($menu, $path);
-
-      // add add page_type if not present
-      if (!isset($menu[$path]['page_type'])) {
-        $menu[$path]['page_type'] = 0;
+      try {
+        self::buildBreadcrumb($menu, $path);
+        self::fillMenuValues($menu, $path);
+        self::fillComponentIds($menu, $path);
+        self::buildReturnUrl($menu, $path);
+
+        // add add page_type if not present
+        if (!isset($menu[$path]['page_type'])) {
+          $menu[$path]['page_type'] = 0;
+        }
+      }
+      catch (CRM_Core_Exception $e) {
+        Civi::log()->error('Menu path skipped:' . $e->getMessage());
       }
     }
 
@@ -465,7 +470,7 @@ class CRM_Core_Menu {
    */
   public static function buildReturnUrl(&$menu, $path) {
     if (!isset($menu[$path]['return_url'])) {
-      list($menu[$path]['return_url'], $menu[$path]['return_url_args']) = self::getReturnUrl($menu, $path);
+      [$menu[$path]['return_url'], $menu[$path]['return_url_args']] = self::getReturnUrl($menu, $path);
     }
   }