From a05671d81a2062825e83e8473e6e236bf043916f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 10 Oct 2016 12:25:02 +0200 Subject: [PATCH] Fixed menu items with object id but w/o handler being selectable Fixes #2101 --- .../files/acp/templates/menuItemAdd.tpl | 4 +++- .../lib/acp/form/MenuItemAddForm.class.php | 22 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) 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'); } } } -- 2.20.1