Add missing box menuID update after menu installation
authorMatthias Schmidt <gravatronics@live.com>
Thu, 24 Dec 2015 12:33:19 +0000 (13:33 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 24 Dec 2015 12:33:19 +0000 (13:33 +0100)
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php

index 7fa9572f3e393981cfff882e7a9d84b5af4b973e..76ae7eedb093f171c5f4fec3e12101cfb27e529f 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\box\Box;
 use wcf\data\box\BoxEditor;
 use wcf\data\menu\Menu;
 use wcf\data\menu\MenuEditor;
+use wcf\data\menu\MenuList;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\WCF;
@@ -189,7 +190,22 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        $boxes[$box->identifier] = $box;
                }
                
+               // fetch all menus relevant
+               $menuList = new MenuList();
+               $menuList->getConditionBuilder()->add('identifier IN (?)', [array_keys($this->boxData)]);
+               $menuList->readObjects();
+               
+               $menus = [];
+               foreach ($menuList as $menu) {
+                       $menus[$menu->identifier] = $menu;
+               }
+               
                foreach ($this->boxData as $identifier => $data) {
+                       // connect box with menu
+                       if (isset($menus[$identifier])) {
+                               $data['menuID'] = $menus[$identifier]->menuID;
+                       }
+                       
                        if (isset($boxes[$identifier])) {
                                // skip both 'identifier' and 'packageID' as these properties are immutable
                                unset($data['identifier']);