Replace some (new) occurrences of SystemException with SPL exceptions
authorMatthias Schmidt <gravatronics@live.com>
Mon, 19 Sep 2016 19:40:17 +0000 (21:40 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 19 Sep 2016 19:40:17 +0000 (21:40 +0200)
wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php
wcfsetup/install/files/lib/data/article/CategoryArticleList.class.php
wcfsetup/install/files/lib/data/box/Box.class.php
wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php
wcfsetup/install/files/lib/system/acl/simple/SimpleAclHandler.class.php
wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php

index 4d273d12b245b707a38689890e5a87a823f8dfdb..9034c098a682e4bb60d25bc4cf09db3d938c6497 100644 (file)
@@ -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()) {
index f7fc9d9f96f87f14635c74a3f1fb7aefc78a0bbe..9599f84465031f774738cb064d682a1f948debba 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 namespace wcf\data\article;
 use wcf\data\article\category\ArticleCategory;
-use wcf\system\exception\SystemException;
 
 /**
  * Represents a list of articles in a specific category.
@@ -19,7 +18,7 @@ class CategoryArticleList extends AccessibleArticleList {
         *
         * @param       integer         $categoryID
         * @param       boolean         $includeChildCategories
-        * @throws      SystemException
+        * @throws      \InvalidArgumentException
         */
        public function __construct($categoryID, $includeChildCategories = false) {
                ViewableArticleList::__construct();
@@ -28,7 +27,7 @@ class CategoryArticleList extends AccessibleArticleList {
                if ($includeChildCategories) {
                        $category = ArticleCategory::getCategory($categoryID);
                        if ($category === null) {
-                               throw new SystemException("invalid category id '".$categoryID."' given");
+                               throw new \InvalidArgumentException("invalid category id '".$categoryID."' given");
                        }
                        foreach ($category->getChildCategories() as $category) {
                                if ($category->isAccessible()) {
index b3b297d0ada15cc3bd30c0fd25436c95a2cc7672..ebb34f46bc17e1723e749e67c76d27067478f3c6 100644 (file)
@@ -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);
                                }
                        }
                }
index 2acb6178e36952e45908b538dbc40b0cf06afa56..860f957b6a7b753850303803e2f28325179bf801 100644 (file)
@@ -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);
                                }
                        }
                }
index b7f76f8fe3db85ad7ea5d7cf8592bbb58230ec9c..cc1d2653bb41863e688972edc821ce1a4b954469 100644 (file)
@@ -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
index 9127b00ff1bb85e41fb634d3ca5da4aad1fe02ac..e768df7d71e17f6b7bb63de18fc58c78b8898920 100644 (file)
@@ -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;