From: Alexander Ebert Date: Mon, 10 Oct 2016 10:25:02 +0000 (+0200) Subject: Fixed menu items with object id but w/o handler being selectable X-Git-Tag: 3.0.0_Beta_3~50^2~25 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a05671d81a2062825e83e8473e6e236bf043916f;p=GitHub%2FWoltLab%2FWCF.git Fixed menu items with object id but w/o handler being selectable Fixes #2101 --- diff --git a/wcfsetup/install/files/acp/templates/menuItemAdd.tpl b/wcfsetup/install/files/acp/templates/menuItemAdd.tpl index 6ddef77006..86b4f716d9 100644 --- a/wcfsetup/install/files/acp/templates/menuItemAdd.tpl +++ b/wcfsetup/install/files/acp/templates/menuItemAdd.tpl @@ -127,7 +127,9 @@ {foreach from=$pageNodeList item=pageNode} - + {if !$pageNode->requireObjectID || $pageHandlers[$pageNode->pageID]|isset} + + {/if} {/foreach} {if $errorField == 'pageID'} diff --git a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php index ab23759a0b..57421cbcb8 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php @@ -197,15 +197,21 @@ class MenuItemAddForm extends AbstractForm { } // validate page object id - if (isset($this->pageHandlers[$page->pageID])) { - if ($this->pageHandlers[$page->pageID] && !$this->pageObjectID) { - throw new UserInputException('pageObjectID'); + if ($page->requireObjectID) { + if (isset($this->pageHandlers[$page->pageID])) { + if ($this->pageHandlers[$page->pageID] && !$this->pageObjectID) { + throw new UserInputException('pageObjectID'); + } + + /** @var ILookupPageHandler $handler */ + $handler = $page->getHandler(); + if ($this->pageObjectID && !$handler->isValid($this->pageObjectID)) { + throw new UserInputException('pageObjectID', 'invalid'); + } } - - /** @var ILookupPageHandler $handler */ - $handler = $page->getHandler(); - if ($this->pageObjectID && !$handler->isValid($this->pageObjectID)) { - throw new UserInputException('pageObjectID', 'invalid'); + else { + // page requires an object id, but no handler is registered + throw new UserInputException('pageID', 'invalid'); } } }