Use DatabaseObjectList:: wherever possible
authorMatthias Schmidt <gravatronics@live.com>
Sun, 24 May 2015 10:42:25 +0000 (12:42 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 24 May 2015 10:42:25 +0000 (12:42 +0200)
wcfsetup/install/files/lib/data/application/ViewableApplicationList.class.php
wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php
wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php
wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php
wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php
wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php
wcfsetup/install/files/lib/data/user/follow/UserFollowerList.class.php
wcfsetup/install/files/lib/system/cache/builder/LabelCacheBuilder.class.php

index 1f6aca7fe886e4cc3098af55d629a2496b55947a..6a1b1aba238040477aabac214b32d50cea168322 100644 (file)
@@ -13,14 +13,7 @@ namespace wcf\data\application;
  */
 class ViewableApplicationList extends ApplicationList {
        /**
-        * @see \wcf\data\DatabaseObjectList::readObjects()
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
         */
-       public function readObjects() {
-               parent::readObjects();
-               
-               foreach ($this->objects as &$application) {
-                       $application = new ViewableApplication($application);
-               }
-               unset($application);
-       }
+       public $decoratorClassName = ViewableApplication::class;
 }
index e4c2b826f0b89970874838f8fc0c1ac13f815e92..fe33bc3180b0d9a60cee13fc7620dab0962c3316 100644 (file)
@@ -47,6 +47,11 @@ class StructuredCommentList extends CommentList {
         */
        public $responseIDs = array();
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = StructuredComment::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlLimit
         */
@@ -84,7 +89,7 @@ class StructuredCommentList extends CommentList {
                
                // fetch response ids
                $responseIDs = $userIDs = array();
-               foreach ($this->objects as &$comment) {
+               foreach ($this->objects as $comment) {
                        if (!$this->minCommentTime || $comment->time < $this->minCommentTime) $this->minCommentTime = $comment->time;
                        $commentResponseIDs = $comment->getResponseIDs();
                        foreach ($commentResponseIDs as $responseID) {
@@ -96,11 +101,9 @@ class StructuredCommentList extends CommentList {
                                $userIDs[] = $comment->userID;
                        }
                        
-                       $comment = new StructuredComment($comment);
                        $comment->setIsDeletable($this->commentManager->canDeleteComment($comment->getDecoratedObject()));
                        $comment->setIsEditable($this->commentManager->canEditComment($comment->getDecoratedObject()));
                }
-               unset($comment);
                
                // fetch last responses
                if (!empty($responseIDs)) {
index 3ec513fcb42579ff7c2f7435bab58e6b09da03b9..a8139a2ec62a2684b0d9c5648df50709309d8549 100644 (file)
@@ -34,6 +34,11 @@ class StructuredCommentResponseList extends CommentResponseList {
         */
        public $minResponseTime = 0;
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = StructuredCommentResponse::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlLimit
         */
@@ -63,15 +68,13 @@ class StructuredCommentResponseList extends CommentResponseList {
                
                // get user ids
                $userIDs = array();
-               foreach ($this->objects as &$response) {
+               foreach ($this->objects as $response) {
                        if (!$this->minResponseTime || $response->time < $this->minResponseTime) $this->minResponseTime = $response->time;
                        $userIDs[] = $response->userID;
                        
-                       $response = new StructuredCommentResponse($response);
                        $response->setIsDeletable($this->commentManager->canDeleteResponse($response->getDecoratedObject()));
                        $response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject()));
                }
-               unset($response);
                
                // fetch user data and avatars
                if (!empty($userIDs)) {
index 78f44738dd3cd606f8ac308a590fca0b3e8f90a9..9199d3178f79e7b66693c786db76fe717dc940ad 100644 (file)
@@ -20,6 +20,11 @@ class ViewableLikeList extends LikeList {
         */
        public $className = 'wcf\data\like\Like';
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = ViewableLike::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlLimit
         */
@@ -40,7 +45,6 @@ class ViewableLikeList extends LikeList {
                $likeGroups = array();
                foreach ($this->objects as &$like) {
                        $userIDs[] = $like->userID;
-                       $like = new ViewableLike($like);
                        
                        if (!isset($likeGroups[$like->objectTypeID])) {
                                $objectType = ObjectTypeCache::getInstance()->getObjectType($like->objectTypeID);
@@ -52,7 +56,6 @@ class ViewableLikeList extends LikeList {
                        
                        $likeGroups[$like->objectTypeID]['objects'][] = $like;
                }
-               unset($like);
                
                // set user profiles
                if (!empty($userIDs)) {
index 0a46ad09160885bec0f13ba3804c8c105b85aad2..1ddd7061afe09d23539ad197015f270ee5d10f73 100644 (file)
@@ -25,6 +25,11 @@ class ViewableModerationQueueList extends ModerationQueueList {
         */
        public $loadUserProfiles = false;
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = ViewableModerationQueue::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$useQualifiedShorthand
         */
@@ -55,15 +60,12 @@ class ViewableModerationQueueList extends ModerationQueueList {
                if (!empty($this->objects)) {
                        $objects = array();
                        foreach ($this->objects as &$object) {
-                               $object = new ViewableModerationQueue($object);
-                               
                                if (!isset($objects[$object->objectTypeID])) {
                                        $objects[$object->objectTypeID] = array();
                                }
                                
                                $objects[$object->objectTypeID][] = $object;
                        }
-                       unset($object);
                        
                        foreach ($objects as $objectTypeID => $queueItems) {
                                ModerationQueueManager::getInstance()->populate($objectTypeID, $queueItems);
index a65509eb2e82cd2846cb8614b4009734f14b0d51..1455c716f7333ab0f6480434ac10d23243f72630 100644 (file)
@@ -21,6 +21,11 @@ class ViewableUserActivityEventList extends UserActivityEventList {
         */
        public $className = 'wcf\data\user\activity\event\UserActivityEvent';
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = ViewableUserActivityEvent::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlLimit
         */
@@ -50,9 +55,8 @@ class ViewableUserActivityEventList extends UserActivityEventList {
                
                $userIDs = array();
                $eventGroups = array();
-               foreach ($this->objects as &$event) {
+               foreach ($this->objects as $event) {
                        $userIDs[] = $event->userID;
-                       $event = new ViewableUserActivityEvent($event);
                        
                        if (!isset($eventGroups[$event->objectTypeID])) {
                                $objectType = UserActivityEventHandler::getInstance()->getObjectType($event->objectTypeID);
@@ -64,7 +68,6 @@ class ViewableUserActivityEventList extends UserActivityEventList {
                        
                        $eventGroups[$event->objectTypeID]['objects'][] = $event;
                }
-               unset($event);
                
                // set user profiles
                if (!empty($userIDs)) {
index 11e52ed41b19ff6524ad5b8383dd31ed82856876..910517bbc28800a3ee2884db10071f08c9e4498c 100644 (file)
@@ -18,6 +18,11 @@ class UserFollowerList extends UserFollowList {
         */
        public $className = 'wcf\data\user\follow\UserFollow';
        
+       /**
+        * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+        */
+       public $decoratorClassName = UserProfile::class;
+       
        /**
         * @see \wcf\data\DatabaseObjectList::$objectClassName
         */
@@ -40,15 +45,4 @@ class UserFollowerList extends UserFollowList {
                $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = user_follow.userID)";
                $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
        }
-       
-       /**
-        * @see \wcf\data\DatabaseObjectList::readObjects()
-        */
-       public function readObjects() {
-               parent::readObjects();
-               
-               foreach ($this->objects as &$object) {
-                       $object = new UserProfile($object);
-               }
-       }
 }
index fd602c2992ca5951bd51fbd7e844f8702031f2a5..2f0c9b39f261fae15c448e3f0ad2ca9a1af51ae8 100644 (file)
@@ -27,12 +27,9 @@ class LabelCacheBuilder extends AbstractCacheBuilder {
                
                // get label groups
                $groupList = new LabelGroupList();
+               $groupList->decoratorClassName = ViewableLabelGroup::class;
                $groupList->readObjects();
-               $groups = $groupList->getObjects();
-               foreach ($groups as &$group) {
-                       $data['groups'][$group->groupID] = new ViewableLabelGroup($group);
-               }
-               unset($group);
+               $data['groups'] = $groupList->getObjects();
                
                // get permissions for groups
                $permissions = ACLHandler::getInstance()->getPermissions(