From ab2e1d138fe7808852f4c1b205350aeb1448325d Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 19 Sep 2016 21:40:17 +0200 Subject: [PATCH] Replace some (new) occurrences of SystemException with SPL exceptions --- .../lib/acp/form/AbstractBulkProcessingForm.class.php | 9 ++++----- .../files/lib/data/article/CategoryArticleList.class.php | 5 ++--- wcfsetup/install/files/lib/data/box/Box.class.php | 6 +++--- .../install/files/lib/data/menu/item/MenuItem.class.php | 6 +++--- .../lib/system/acl/simple/SimpleAclHandler.class.php | 9 ++++----- .../AbstractDatabaseObjectListBoxController.class.php | 7 +++---- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php index 4d273d12b2..9034c098a6 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php @@ -4,7 +4,6 @@ use wcf\data\object\type\ObjectType; use wcf\data\object\type\ObjectTypeCache; use wcf\form\AbstractForm; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -83,12 +82,12 @@ abstract class AbstractBulkProcessingForm extends AbstractForm { // read bulk processable object type $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.bulkProcessableObject', $this->objectTypeName); if ($this->objectType === null) { - throw new SystemException("Unknown bulk processable object type '".$this->objectTypeName."'"); + throw new \LogicException("Unknown bulk processable object type '".$this->objectTypeName."'"); } // read conditions if (ObjectTypeCache::getInstance()->getDefinitionByName($this->objectType->getProcessor()->getConditionObjectTypeDefinition()) === null) { - throw new SystemException("Unknown condition object type definition '".$this->objectType->getProcessor()->getConditionObjectTypeDefinition()."'"); + throw new \LogicException("Unknown condition object type definition '".$this->objectType->getProcessor()->getConditionObjectTypeDefinition()."'"); } $conditionObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes($this->objectType->getProcessor()->getConditionObjectTypeDefinition()); if (empty($conditionObjectTypes)) { @@ -110,13 +109,13 @@ abstract class AbstractBulkProcessingForm extends AbstractForm { // read actions if (ObjectTypeCache::getInstance()->getDefinitionByName($this->objectType->getProcessor()->getActionObjectTypeDefinition()) === null) { - throw new SystemException("Unknown action object type definition '".$this->objectType->getProcessor()->getActionObjectTypeDefinition()."'"); + throw new \LogicException("Unknown action object type definition '".$this->objectType->getProcessor()->getActionObjectTypeDefinition()."'"); } $actions = ObjectTypeCache::getInstance()->getObjectTypes($this->objectType->getProcessor()->getActionObjectTypeDefinition()); foreach ($actions as $objectType) { if (isset($this->actions[$objectType->action])) { - throw new SystemException("Duplicate action with name '".$objectType->action."'"); + throw new \LogicException("Duplicate action with name '".$objectType->action."'"); } if ($objectType->validateOptions() && $objectType->validatePermissions()) { diff --git a/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php b/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php index f7fc9d9f96..9599f84465 100644 --- a/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php +++ b/wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php @@ -1,7 +1,6 @@ getChildCategories() as $category) { if ($category->isAccessible()) { diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index b3b297d0ad..ebb34f46bc 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -13,7 +13,7 @@ use wcf\system\condition\ConditionHandler; use wcf\data\page\Page; use wcf\data\page\PageCache; use wcf\data\DatabaseObject; -use wcf\system\exception\SystemException; +use wcf\system\exception\ImplementationException; use wcf\system\html\output\HtmlOutputProcessor; use wcf\system\page\handler\ILookupPageHandler; use wcf\system\page\handler\IMenuPageHandler; @@ -397,7 +397,7 @@ class Box extends DatabaseObject { * Returns the IMenuPageHandler of the linked page. * * @return IMenuPageHandler|null - * @throws SystemException + * @throws ImplementationException */ protected function getLinkPageHandler() { $page = $this->getLinkPage(); @@ -406,7 +406,7 @@ class Box extends DatabaseObject { $className = $page->handler; $this->linkPageHandler = new $className; if (!($this->linkPageHandler instanceof IMenuPageHandler)) { - throw new SystemException("Expected a valid handler implementing '" . IMenuPageHandler::class . "'."); + throw new ImplementationException(get_class($this->linkPageHandler), IMenuPageHandler::class); } } } diff --git a/wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php b/wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php index 2acb6178e3..860f957b6a 100644 --- a/wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php +++ b/wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php @@ -3,7 +3,7 @@ namespace wcf\data\menu\item; use wcf\data\page\Page; use wcf\data\page\PageCache; use wcf\data\DatabaseObject; -use wcf\system\exception\SystemException; +use wcf\system\exception\ImplementationException; use wcf\system\page\handler\ILookupPageHandler; use wcf\system\page\handler\IMenuPageHandler; use wcf\system\WCF; @@ -140,7 +140,7 @@ class MenuItem extends DatabaseObject { * Returns the page handler for this item. * * @return IMenuPageHandler|null - * @throws SystemException + * @throws ImplementationException */ protected function getMenuPageHandler() { $page = $this->getPage(); @@ -149,7 +149,7 @@ class MenuItem extends DatabaseObject { $className = $this->getPage()->handler; $this->handler = new $className; if (!($this->handler instanceof IMenuPageHandler)) { - throw new SystemException("Expected a valid handler implementing '" . IMenuPageHandler::class . "'."); + throw new ImplementationException(get_class($this->handler), IMenuPageHandler::class); } } } diff --git a/wcfsetup/install/files/lib/system/acl/simple/SimpleAclHandler.class.php b/wcfsetup/install/files/lib/system/acl/simple/SimpleAclHandler.class.php index b7f76f8fe3..cc1d2653bb 100644 --- a/wcfsetup/install/files/lib/system/acl/simple/SimpleAclHandler.class.php +++ b/wcfsetup/install/files/lib/system/acl/simple/SimpleAclHandler.class.php @@ -5,7 +5,6 @@ use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\group\UserGroup; use wcf\data\user\User; use wcf\system\cache\runtime\UserRuntimeCache; -use wcf\system\exception\SystemException; use wcf\system\SingletonFactory; use wcf\system\WCF; use wcf\util\ArrayUtil; @@ -38,11 +37,11 @@ class SimpleAclHandler extends SingletonFactory { * * @param string $objectType object type name * @return integer object type id - * @throws SystemException + * @throws \InvalidArgumentException */ public function getObjectTypeID($objectType) { if (!isset($this->objectTypes[$objectType])) { - throw new SystemException("Unknown object type '" . $objectType . "'"); + throw new \InvalidArgumentException("Unknown object type '" . $objectType . "'"); } return $this->objectTypes[$objectType]->objectTypeID; @@ -107,14 +106,14 @@ class SimpleAclHandler extends SingletonFactory { * @param string $objectType object type name * @param integer $objectID object id * @param array $values list of user and group ids - * @throws SystemException + * @throws \InvalidArgumentException */ public function setValues($objectType, $objectID, array $values) { $objectTypeID = $this->getObjectTypeID($objectType); // validate data of `$values` if (empty($values['user']) && empty($values['group']) && !isset($values['allowAll'])) { - throw new SystemException("Missing ACL configuration values."); + throw new \InvalidArgumentException("Missing ACL configuration values."); } // users diff --git a/wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php b/wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php index 9127b00ff1..e768df7d71 100644 --- a/wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php @@ -8,7 +8,6 @@ use wcf\data\DatabaseObjectList; use wcf\system\condition\ConditionHandler; use wcf\system\condition\IObjectListCondition; use wcf\system\event\EventHandler; -use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\WCF; use wcf\util\StringUtil; @@ -100,12 +99,12 @@ abstract class AbstractDatabaseObjectListBoxController extends AbstractBoxContro /** * Creates a new instance of AbstractDynamicBoxController. * - * @throws SystemException + * @throws \LogicException */ public function __construct() { if ($this->conditionDefinition) { if (ObjectTypeCache::getInstance()->getDefinitionByName($this->conditionDefinition) === null) { - throw new SystemException("Unknown object type definition '" . $this->conditionDefinition . "'"); + throw new \LogicException("Unknown object type definition '" . $this->conditionDefinition . "'"); } $this->conditionObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes($this->conditionDefinition); @@ -117,7 +116,7 @@ abstract class AbstractDatabaseObjectListBoxController extends AbstractBoxContro if ($this->defaultLimit !== null) { if ($this->defaultLimit <= 0) { - throw new SystemException("The default limit may has to be positive."); + throw new \LogicException("The default limit may has to be positive."); } $this->limit = $this->defaultLimit; -- 2.20.1