From 55baeaacc7dc4b627440af2f106759ab6eda2df1 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 24 May 2015 12:42:25 +0200 Subject: [PATCH] Use DatabaseObjectList:: wherever possible --- .../ViewableApplicationList.class.php | 11 ++--------- .../data/comment/StructuredCommentList.class.php | 9 ++++++--- .../StructuredCommentResponseList.class.php | 9 ++++++--- .../lib/data/like/ViewableLikeList.class.php | 7 +++++-- .../queue/ViewableModerationQueueList.class.php | 8 +++++--- .../ViewableUserActivityEventList.class.php | 9 ++++++--- .../data/user/follow/UserFollowerList.class.php | 16 +++++----------- .../cache/builder/LabelCacheBuilder.class.php | 7 ++----- 8 files changed, 37 insertions(+), 39 deletions(-) diff --git a/wcfsetup/install/files/lib/data/application/ViewableApplicationList.class.php b/wcfsetup/install/files/lib/data/application/ViewableApplicationList.class.php index 1f6aca7fe8..6a1b1aba23 100644 --- a/wcfsetup/install/files/lib/data/application/ViewableApplicationList.class.php +++ b/wcfsetup/install/files/lib/data/application/ViewableApplicationList.class.php @@ -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; } diff --git a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php index e4c2b826f0..fe33bc3180 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php @@ -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)) { diff --git a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php index 3ec513fcb4..a8139a2ec6 100644 --- a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php @@ -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)) { diff --git a/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php b/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php index 78f44738dd..9199d3178f 100644 --- a/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php +++ b/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php @@ -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)) { diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php index 0a46ad0916..1ddd7061af 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php @@ -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); diff --git a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php index a65509eb2e..1455c716f7 100644 --- a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php +++ b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEventList.class.php @@ -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)) { diff --git a/wcfsetup/install/files/lib/data/user/follow/UserFollowerList.class.php b/wcfsetup/install/files/lib/data/user/follow/UserFollowerList.class.php index 11e52ed41b..910517bbc2 100644 --- a/wcfsetup/install/files/lib/data/user/follow/UserFollowerList.class.php +++ b/wcfsetup/install/files/lib/data/user/follow/UserFollowerList.class.php @@ -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); - } - } } diff --git a/wcfsetup/install/files/lib/system/cache/builder/LabelCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LabelCacheBuilder.class.php index fd602c2992..2f0c9b39f2 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/LabelCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/LabelCacheBuilder.class.php @@ -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( -- 2.20.1