Fix searching for menu items in the ACP
authorMatthias Schmidt <gravatronics@live.com>
Tue, 3 Mar 2015 16:13:25 +0000 (17:13 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 3 Mar 2015 16:13:25 +0000 (17:13 +0100)
wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php

index 41fad90497336b5594517a2e4ce898973c4fa448..3fabb36b7c99a843e318b766bacd208f07f979a7 100644 (file)
@@ -61,17 +61,20 @@ class MenuItemACPSearchResultProvider extends AbstractACPSearchResultProvider im
                $statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
                $statement->execute($conditions->getParameters());
                
+               $menuItems = ACPMenu::getInstance()->menuItemList;
                while ($menuItem = $statement->fetchObject('wcf\data\acp\menu\item\ACPMenuItem')) {
-                       if (!$this->validate($menuItem)) {
+                       // only valid menu items exist in TreeMenu::$menuItemList,
+                       // so no need to call AbstractACPSearchResultProvider::validate()
+                       if (!isset($menuItems[$menuItem->menuItem])) {
                                continue;
                        }
                        
                        $parentMenuItem = $menuItem->parentMenuItem;
                        $parentMenuItems = array();
-                       while ($parentMenuItem && isset(ACPMenu::getInstance()->menuItems[$parentMenuItem])) {
+                       while ($parentMenuItem && isset($menuItems[$parentMenuItem])) {
                                array_unshift($parentMenuItems, $parentMenuItem);
                                
-                               $parentMenuItem = ACPMenu::getInstance()->menuItemList[$parentMenuItem]->parentMenuItem;
+                               $parentMenuItem = $menuItems[$parentMenuItem]->parentMenuItem;
                        }
                        $results[] = new ACPSearchResult($languageItems[$menuItem->menuItem], $menuItem->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array(
                                'pieces' => $parentMenuItems