From 9a66ae927a22ae3d5d3da1641af41311741f0e67 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 26 Mar 2016 17:25:52 +0100 Subject: [PATCH] Add runtime cache API --- .../data/comment/StructuredComment.class.php | 30 ++-- .../comment/StructuredCommentList.class.php | 41 ++--- .../data/comment/ViewableComment.class.php | 26 ++-- .../comment/ViewableCommentList.class.php | 15 +- .../StructuredCommentResponse.class.php | 22 +-- .../StructuredCommentResponseList.class.php | 31 ++-- .../ViewableCommentResponse.class.php | 26 ++-- .../ViewableCommentResponseList.class.php | 15 +- .../lib/data/like/ViewableLike.class.php | 16 +- .../lib/data/like/ViewableLikeList.class.php | 18 +-- .../queue/ViewableModerationQueue.class.php | 6 +- .../ViewableModerationQueueList.class.php | 26 ++-- .../files/lib/data/user/UserProfile.class.php | 100 ++++++------ .../lib/data/user/UserProfileCache.class.php | 88 ++--------- .../event/ViewableUserActivityEvent.class.php | 16 +- .../ViewableUserActivityEventList.class.php | 36 ++--- .../runtime/AbstractRuntimeCache.class.php | 142 ++++++++++++++++++ .../runtime/CommentRuntimeCache.class.php | 25 +++ .../cache/runtime/IRuntimeCache.class.php | 75 +++++++++ .../runtime/UserProfileRuntimeCache.class.php | 25 +++ .../comment/CommentDataHandler.class.php | 76 ++-------- .../MostActiveMembersDashboardBox.class.php | 22 +-- .../MostLikedMembersDashboardBox.class.php | 22 +-- .../box/NewestMembersDashboardBox.class.php | 22 +-- .../box/TodaysBirthdaysDashboardBox.class.php | 21 +-- ...ysFollowingBirthdaysDashboardBox.class.php | 6 +- .../HtmlOutputNodeWoltlabMention.class.php | 4 +- ...uoteMessageEmbeddedObjectHandler.class.php | 12 +- ...CommentResponseUserActivityEvent.class.php | 18 +-- .../ProfileCommentUserActivityEvent.class.php | 8 +- ...entResponseUserNotificationEvent.class.php | 26 ++-- ...CommentLikeUserNotificationEvent.class.php | 46 +++--- ...esponseLikeUserNotificationEvent.class.php | 50 +++--- ...sponseOwnerUserNotificationEvent.class.php | 58 +++---- ...entResponseUserNotificationEvent.class.php | 59 ++++---- ...ommentUserNotificationObjectType.class.php | 4 +- 36 files changed, 700 insertions(+), 533 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/cache/runtime/AbstractRuntimeCache.class.php create mode 100644 wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php create mode 100644 wcfsetup/install/files/lib/system/cache/runtime/IRuntimeCache.class.php create mode 100644 wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php diff --git a/wcfsetup/install/files/lib/data/comment/StructuredComment.class.php b/wcfsetup/install/files/lib/data/comment/StructuredComment.class.php index 1aca1fd789..544b43a4a6 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredComment.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredComment.class.php @@ -3,14 +3,14 @@ namespace wcf\data\comment; use wcf\data\comment\response\StructuredCommentResponse; use wcf\data\user\User; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; +use wcf\system\cache\runtime\UserProfileRuntimeCache; /** * Provides methods to handle responses for this comment. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.comment @@ -18,15 +18,15 @@ use wcf\data\DatabaseObjectDecorator; */ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \Iterator { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - public static $baseClass = 'wcf\data\comment\Comment'; + public static $baseClass = Comment::class; /** * list of ordered responses - * @var array<\wcf\data\comment\response\StructuredCommentResponse> + * @var StructuredCommentResponse[] */ - protected $responses = array(); + protected $responses = []; /** * deletable by current user @@ -47,15 +47,15 @@ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \ private $position = 0; /** - * user profile object - * @var \wcf\data\user\UserProfile + * user profile object of the comment author + * @var UserProfile */ public $userProfile = null; /** * Adds an response * - * @param \wcf\data\comment\response\StructuredCommentResponse $response + * @param StructuredCommentResponse $response */ public function addResponse(StructuredCommentResponse $response) { $this->responses[] = $response; @@ -64,7 +64,7 @@ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \ /** * Returns the last responses for this comment. * - * @return array<\wcf\data\comment\response\StructuredCommentResponse> + * @return StructuredCommentResponse[] */ public function getResponses() { return $this->responses; @@ -91,7 +91,7 @@ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \ /** * Sets the user's profile. * - * @param \wcf\data\user\UserProfile $userProfile + * @param UserProfile $userProfile */ public function setUserProfile(UserProfile $userProfile) { $this->userProfile = $userProfile; @@ -100,17 +100,17 @@ class StructuredComment extends DatabaseObjectDecorator implements \Countable, \ /** * Returns the user's profile. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { if ($this->userID) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } else { - $this->userProfile = new UserProfile(new User(null, array( + $this->userProfile = new UserProfile(new User(null, [ 'username' => $this->username - ))); + ])); } } diff --git a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php index a78d9f6beb..8992261021 100644 --- a/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php @@ -2,7 +2,8 @@ namespace wcf\data\comment; use wcf\data\comment\response\CommentResponseList; use wcf\data\comment\response\StructuredCommentResponse; -use wcf\data\user\UserProfileCache; +use wcf\data\like\object\LikeObject; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\comment\manager\ICommentManager; use wcf\system\like\LikeHandler; @@ -10,7 +11,7 @@ use wcf\system\like\LikeHandler; * Provides a structured comment list fetching last responses for every comment. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.comment @@ -19,7 +20,7 @@ use wcf\system\like\LikeHandler; class StructuredCommentList extends CommentList { /** * comment manager object - * @var \wcf\system\comment\manager\ICommentManager + * @var ICommentManager */ public $commentManager = null; @@ -43,31 +44,31 @@ class StructuredCommentList extends CommentList { /** * ids of the responses of the comments in the list - * @var array + * @var integer[] */ - public $responseIDs = array(); + public $responseIDs = []; /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ public $decoratorClassName = StructuredComment::class; /** - * @see \wcf\data\DatabaseObjectList::$sqlLimit + * @inheritDoc */ public $sqlLimit = 30; /** - * @see \wcf\data\DatabaseObjectList::$sqlOrderBy + * @inheritDoc */ public $sqlOrderBy = 'comment.time DESC'; /** * Creates a new structured comment list. * - * @param \wcf\system\comment\manager\ICommentManager $commentManager - * @param integer $objectTypeID - * @param integer $objectID + * @param ICommentManager $commentManager + * @param integer $objectTypeID + * @param integer $objectID */ public function __construct(ICommentManager $commentManager, $objectTypeID, $objectID) { parent::__construct(); @@ -76,19 +77,19 @@ class StructuredCommentList extends CommentList { $this->objectTypeID = $objectTypeID; $this->objectID = $objectID; - $this->getConditionBuilder()->add("comment.objectTypeID = ?", array($objectTypeID)); - $this->getConditionBuilder()->add("comment.objectID = ?", array($objectID)); + $this->getConditionBuilder()->add("comment.objectTypeID = ?", [$objectTypeID]); + $this->getConditionBuilder()->add("comment.objectID = ?", [$objectID]); $this->sqlLimit = $this->commentManager->getCommentsPerPage(); } /** - * @see \wcf\data\DatabaseObjectList::readObjects() + * @inheritDoc */ public function readObjects() { parent::readObjects(); // fetch response ids - $responseIDs = $userIDs = array(); + $responseIDs = $userIDs = []; foreach ($this->objects as $comment) { if (!$this->minCommentTime || $comment->time < $this->minCommentTime) $this->minCommentTime = $comment->time; $commentResponseIDs = $comment->getResponseIDs(); @@ -127,19 +128,19 @@ class StructuredCommentList extends CommentList { // cache user ids if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs)); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs)); } } /** * Fetches the like data. * - * @return array + * @return LikeObject[][] */ public function getLikeData() { - if (empty($this->objectIDs)) return array(); + if (empty($this->objectIDs)) return []; - $likeData = array(); + $likeData = []; $commentObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment'); LikeHandler::getInstance()->loadLikeObjects($commentObjectType, $this->getObjectIDs()); $likeData['comment'] = LikeHandler::getInstance()->getLikeObjects($commentObjectType); @@ -165,7 +166,7 @@ class StructuredCommentList extends CommentList { /** * Returns the comment manager object. * - * @return \wcf\system\comment\manager\ICommentManager + * @return ICommentManager */ public function getCommentManager() { return $this->commentManager; diff --git a/wcfsetup/install/files/lib/data/comment/ViewableComment.class.php b/wcfsetup/install/files/lib/data/comment/ViewableComment.class.php index f505207ce8..34d749556b 100644 --- a/wcfsetup/install/files/lib/data/comment/ViewableComment.class.php +++ b/wcfsetup/install/files/lib/data/comment/ViewableComment.class.php @@ -2,15 +2,15 @@ namespace wcf\data\comment; use wcf\data\user\User; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; use wcf\data\TLegacyUserPropertyAccess; +use wcf\system\cache\runtime\UserProfileRuntimeCache; /** * Represents a viewable comment. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.comment @@ -20,30 +20,30 @@ class ViewableComment extends DatabaseObjectDecorator { use TLegacyUserPropertyAccess; /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - protected static $baseClass = 'wcf\data\comment\Comment'; + protected static $baseClass = Comment::class; /** - * user profile object - * @var \wcf\data\user\UserProfile + * user profile of the comment author + * @var UserProfile */ protected $userProfile = null; /** * Returns the user profile object. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { if ($this->userID) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } else { - $this->userProfile = new UserProfile(new User(null, array( + $this->userProfile = new UserProfile(new User(null, [ 'username' => $this->username - ))); + ])); } } @@ -51,14 +51,14 @@ class ViewableComment extends DatabaseObjectDecorator { } /** - * Gets a specific comment decorated as comment entry. + * Returns a specific comment decorated as comment entry. * * @param integer $commentID - * @return \wcf\data\comment\ViewableComment + * @return ViewableComment */ public static function getComment($commentID) { $list = new ViewableCommentList(); - $list->setObjectIDs(array($commentID)); + $list->setObjectIDs([$commentID]); $list->readObjects(); $objects = $list->getObjects(); if (isset($objects[$commentID])) return $objects[$commentID]; diff --git a/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php b/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php index 89b8db4c54..e2ab16f0b8 100644 --- a/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php +++ b/wcfsetup/install/files/lib/data/comment/ViewableCommentList.class.php @@ -1,12 +1,12 @@ * @package com.woltlab.wcf * @subpackage data.comment @@ -14,15 +14,18 @@ use wcf\data\user\UserProfileCache; */ class ViewableCommentList extends CommentList { /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ - public $decoratorClassName = 'wcf\data\comment\ViewableComment'; + public $decoratorClassName = ViewableComment::class; + /** + * @inheritDoc + */ public function readObjects() { parent::readObjects(); if (!empty($this->objects)) { - $userIDs = array(); + $userIDs = []; foreach ($this->objects as $comment) { if ($comment->userID) { $userIDs[] = $comment->userID; @@ -30,7 +33,7 @@ class ViewableCommentList extends CommentList { } if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs($userIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } } } diff --git a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php index 9ead82e6fb..b4eef2f3bb 100644 --- a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponse.class.php @@ -2,14 +2,14 @@ namespace wcf\data\comment\response; use wcf\data\user\User; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; +use wcf\system\cache\runtime\UserProfileRuntimeCache; /** * Provides methods to handle response data. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.comment.response @@ -17,9 +17,9 @@ use wcf\data\DatabaseObjectDecorator; */ class StructuredCommentResponse extends DatabaseObjectDecorator { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - public static $baseClass = 'wcf\data\comment\response\CommentResponse'; + public static $baseClass = CommentResponse::class; /** * deletable by current user @@ -34,15 +34,15 @@ class StructuredCommentResponse extends DatabaseObjectDecorator { public $editable = false; /** - * user profile object - * @var \wcf\data\user\UserProfile + * user profile of the comment response author + * @var UserProfile */ public $userProfile = null; /** * Sets the user's profile. * - * @param \wcf\data\user\UserProfile $userProfile + * @param UserProfile $userProfile */ public function setUserProfile(UserProfile $userProfile) { $this->userProfile = $userProfile; @@ -51,12 +51,12 @@ class StructuredCommentResponse extends DatabaseObjectDecorator { /** * Returns the user's profile. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { if ($this->userID) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } else { $this->userProfile = new UserProfile(new User(null, array( @@ -72,7 +72,7 @@ class StructuredCommentResponse extends DatabaseObjectDecorator { * Returns a structured response. * * @param integer $responseID - * @return \wcf\data\comment\response\StructuredCommentResponse + * @return StructuredCommentResponse */ public static function getResponse($responseID) { $response = new CommentResponse($responseID); @@ -85,7 +85,7 @@ class StructuredCommentResponse extends DatabaseObjectDecorator { // cache user profile if ($response->userID) { - UserProfileCache::getInstance()->cacheUserID($response->userID); + UserProfileRuntimeCache::getInstance()->cacheObjectID($response->userID); } return $response; 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 67e02014bd..5055f02073 100644 --- a/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/StructuredCommentResponseList.class.php @@ -1,7 +1,8 @@ * @package com.woltlab.wcf * @subpackage data.comment.response @@ -18,13 +19,13 @@ use wcf\system\like\LikeHandler; class StructuredCommentResponseList extends CommentResponseList { /** * comment object - * @var \wcf\data\comment\Comment; + * @var Comment; */ public $comment = null; /** * comment manager - * @var \wcf\system\comment\manager\ICommentManager + * @var ICommentManager */ public $commentManager = null; @@ -35,20 +36,20 @@ class StructuredCommentResponseList extends CommentResponseList { public $minResponseTime = 0; /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ public $decoratorClassName = StructuredCommentResponse::class; /** - * @see \wcf\data\DatabaseObjectList::$sqlLimit + * @inheritDoc */ public $sqlLimit = 50; /** * Creates a new structured comment response list. * - * @param \wcf\system\comment\manager\ICommentManager $commentManager - * @param \wcf\data\comment\Comment $comment + * @param ICommentManager $commentManager + * @param Comment $comment */ public function __construct(ICommentManager $commentManager, Comment $comment) { parent::__construct(); @@ -56,18 +57,18 @@ class StructuredCommentResponseList extends CommentResponseList { $this->comment = $comment; $this->commentManager = $commentManager; - $this->getConditionBuilder()->add("comment_response.commentID = ?", array($this->comment->commentID)); + $this->getConditionBuilder()->add("comment_response.commentID = ?", [$this->comment->commentID]); $this->sqlLimit = $this->commentManager->getCommentsPerPage(); } /** - * @see \wcf\data\DatabaseObjectList::readObjects() + * @inheritDoc */ public function readObjects() { parent::readObjects(); // get user ids - $userIDs = array(); + $userIDs = []; foreach ($this->objects as $response) { if (!$this->minResponseTime || $response->time < $this->minResponseTime) $this->minResponseTime = $response->time; $userIDs[] = $response->userID; @@ -78,21 +79,21 @@ class StructuredCommentResponseList extends CommentResponseList { // cache user ids if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs)); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs)); } } /** * Fetches the like data. * - * @return array + * @return LikeObject[][] */ public function getLikeData() { - if (empty($this->objectIDs)) return array(); + if (empty($this->objectIDs)) return []; $objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment.response'); LikeHandler::getInstance()->loadLikeObjects($objectType, $this->objectIDs); - $likeData = array('response' => LikeHandler::getInstance()->getLikeObjects($objectType)); + $likeData = ['response' => LikeHandler::getInstance()->getLikeObjects($objectType)]; return $likeData; } diff --git a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponse.class.php b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponse.class.php index 63c88d99cc..507cabfaf3 100644 --- a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponse.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponse.class.php @@ -2,15 +2,15 @@ namespace wcf\data\comment\response; use wcf\data\user\User; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; use wcf\data\TLegacyUserPropertyAccess; +use wcf\system\cache\runtime\UserProfileRuntimeCache; /** * Represents a viewable comment response. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.comment.response @@ -20,30 +20,30 @@ class ViewableCommentResponse extends DatabaseObjectDecorator { use TLegacyUserPropertyAccess; /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - protected static $baseClass = 'wcf\data\comment\response\CommentResponse'; + protected static $baseClass = CommentResponse::class; /** - * user profile object - * @var \wcf\data\user\UserProfile + * user profile of the comment author + * @var UserProfile */ protected $userProfile = null; /** * Returns the user profile object. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { if ($this->userID) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } else { - $this->userProfile = new UserProfile(new User(null, array( + $this->userProfile = new UserProfile(new User(null, [ 'username' => $this->username - ))); + ])); } } @@ -51,14 +51,14 @@ class ViewableCommentResponse extends DatabaseObjectDecorator { } /** - * Gets a specific comment response decorated as viewable comment response. + * Returns a specific comment response decorated as viewable comment response. * * @param integer $responseID - * @return \wcf\data\comment\response\ViewableCommentResponse + * @return ViewableCommentResponse */ public static function getResponse($responseID) { $list = new ViewableCommentResponseList(); - $list->setObjectIDs(array($responseID)); + $list->setObjectIDs([$responseID]); $list->readObjects(); $objects = $list->getObjects(); if (isset($objects[$responseID])) return $objects[$responseID]; diff --git a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php index 97b9f84548..dd33c9e216 100644 --- a/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php +++ b/wcfsetup/install/files/lib/data/comment/response/ViewableCommentResponseList.class.php @@ -1,12 +1,12 @@ * @package com.woltlab.wcf * @subpackage data.comment.response @@ -14,15 +14,18 @@ use wcf\data\user\UserProfileCache; */ class ViewableCommentResponseList extends CommentResponseList { /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ - public $decoratorClassName = 'wcf\data\comment\response\ViewableCommentResponse'; + public $decoratorClassName = ViewableCommentResponse::class; + /** + * @inheritDoc + */ public function readObjects() { parent::readObjects(); if (!empty($this->objects)) { - $userIDs = array(); + $userIDs = []; foreach ($this->objects as $response) { if ($response->userID) { $userIDs[] = $response->userID; @@ -30,7 +33,7 @@ class ViewableCommentResponseList extends CommentResponseList { } if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs($userIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } } } diff --git a/wcfsetup/install/files/lib/data/like/ViewableLike.class.php b/wcfsetup/install/files/lib/data/like/ViewableLike.class.php index 4c860373d0..c61d66295f 100644 --- a/wcfsetup/install/files/lib/data/like/ViewableLike.class.php +++ b/wcfsetup/install/files/lib/data/like/ViewableLike.class.php @@ -2,14 +2,14 @@ namespace wcf\data\like; use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; +use wcf\system\cache\runtime\UserProfileRuntimeCache; /** * Provides methods for viewable likes. * * @author Marcel Werk - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.like @@ -17,9 +17,9 @@ use wcf\data\DatabaseObjectDecorator; */ class ViewableLike extends DatabaseObjectDecorator { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - public static $baseClass = 'wcf\data\like\Like'; + public static $baseClass = Like::class; /** * event text @@ -41,7 +41,7 @@ class ViewableLike extends DatabaseObjectDecorator { /** * user profile - * @var \wcf\data\user\UserProfile + * @var UserProfile */ protected $userProfile = null; @@ -64,7 +64,7 @@ class ViewableLike extends DatabaseObjectDecorator { /** * Sets user profile. * - * @param \wcf\data\user\UserProfile $userProfile + * @param UserProfile $userProfile */ public function setUserProfile(UserProfile $userProfile) { $this->userProfile = $userProfile; @@ -73,11 +73,11 @@ class ViewableLike extends DatabaseObjectDecorator { /** * Returns user profile. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } return $this->userProfile; diff --git a/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php b/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php index 21e15489e9..0753fdba1c 100644 --- a/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php +++ b/wcfsetup/install/files/lib/data/like/ViewableLikeList.class.php @@ -1,14 +1,14 @@ * @package com.woltlab.wcf * @subpackage data.like @@ -16,27 +16,27 @@ use wcf\system\like\IViewableLikeProvider; */ class ViewableLikeList extends LikeList { /** - * @see \wcf\data\DatabaseObjectList::$className + * @inheritDoc */ - public $className = 'wcf\data\like\Like'; + public $className = Like::class; /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ public $decoratorClassName = ViewableLike::class; /** - * @see \wcf\data\DatabaseObjectList::$sqlLimit + * @inheritDoc */ public $sqlLimit = 20; /** - * @see \wcf\data\DatabaseObjectList::$sqlOrderBy + * @inheritDoc */ public $sqlOrderBy = 'like_table.time DESC'; /** - * @see \wcf\data\DatabaseObjectList::readObjects() + * @inheritDoc */ public function readObjects() { parent::readObjects(); @@ -59,7 +59,7 @@ class ViewableLikeList extends LikeList { // set user profiles if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs)); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs)); } // parse like diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueue.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueue.class.php index c0bc60e432..f126ea98fa 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueue.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueue.class.php @@ -3,12 +3,12 @@ namespace wcf\data\moderation\queue; use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\User; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\data\DatabaseObjectDecorator; use wcf\data\ILinkableObject; use wcf\data\ITitledObject; use wcf\data\IUserContent; use wcf\system\bbcode\SimpleMessageParser; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\moderation\queue\ModerationQueueManager; use wcf\system\visitTracker\VisitTracker; @@ -16,7 +16,7 @@ use wcf\system\visitTracker\VisitTracker; * Represents a viewable moderation queue entry. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.moderation.queue @@ -97,7 +97,7 @@ class ViewableModerationQueue extends DatabaseObjectDecorator implements ILinkab public function getUserProfile() { if ($this->affectedObject !== null && $this->userProfile === null) { if ($this->affectedObject->getUserID()) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->affectedObject->getUserID()); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->affectedObject->getUserID()); } else { $this->userProfile = new UserProfile(new User(null, [])); 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 7c6d6556a1..ca0bd84aea 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ViewableModerationQueueList.class.php @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage data.moderation.queue @@ -26,17 +26,17 @@ class ViewableModerationQueueList extends ModerationQueueList { public $loadUserProfiles = false; /** - * @see \wcf\data\DatabaseObjectList::$decoratorClassName + * @inheritDoc */ public $decoratorClassName = ViewableModerationQueue::class; /** - * @see \wcf\data\DatabaseObjectList::$useQualifiedShorthand + * @inheritDoc */ public $useQualifiedShorthand = false; /** - * @see \wcf\data\DatabaseObjectList::__construct() + * @inheritDoc */ public function __construct() { parent::__construct(); @@ -47,21 +47,21 @@ class ViewableModerationQueueList extends ModerationQueueList { $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user assigned_user ON (assigned_user.userID = moderation_queue.assignedUserID)"; $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = moderation_queue.userID)"; $this->getConditionBuilder()->add("moderation_queue_to_user.queueID = moderation_queue.queueID"); - $this->getConditionBuilder()->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID)); - $this->getConditionBuilder()->add("moderation_queue_to_user.isAffected = ?", array(1)); + $this->getConditionBuilder()->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]); + $this->getConditionBuilder()->add("moderation_queue_to_user.isAffected = ?", [1]); } /** - * @see \wcf\data\DatabaseObjectList::readObjects() + * @inheritDoc */ public function readObjects() { parent::readObjects(); if (!empty($this->objects)) { - $objects = array(); + $objects = []; foreach ($this->objects as &$object) { if (!isset($objects[$object->objectTypeID])) { - $objects[$object->objectTypeID] = array(); + $objects[$object->objectTypeID] = []; } $objects[$object->objectTypeID][] = $object; @@ -72,7 +72,7 @@ class ViewableModerationQueueList extends ModerationQueueList { } // check for non-existant items - $queueIDs = array(); + $queueIDs = []; foreach ($this->objects as $index => $object) { if ($object->isOrphaned()) { $queueIDs[] = $object->queueID; @@ -88,12 +88,12 @@ class ViewableModerationQueueList extends ModerationQueueList { } if ($this->loadUserProfiles) { - $userIDs = array(); + $userIDs = []; foreach ($this->objects as $object) { $userIDs[] = $object->getAffectedObject()->getUserID(); } - UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs)); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs)); } } } diff --git a/wcfsetup/install/files/lib/data/user/UserProfile.class.php b/wcfsetup/install/files/lib/data/user/UserProfile.class.php index aa2129da4e..68efae2148 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfile.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfile.class.php @@ -2,6 +2,7 @@ namespace wcf\data\user; use wcf\data\user\avatar\DefaultAvatar; use wcf\data\user\avatar\Gravatar; +use wcf\data\user\avatar\IUserAvatar; use wcf\data\user\avatar\UserAvatar; use wcf\data\user\group\UserGroup; use wcf\data\user\online\UserOnline; @@ -11,6 +12,7 @@ use wcf\data\DatabaseObjectDecorator; use wcf\system\breadcrumb\Breadcrumb; use wcf\system\breadcrumb\IBreadcrumbProvider; use wcf\system\cache\builder\UserGroupPermissionCacheBuilder; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\request\LinkHandler; use wcf\system\user\online\location\UserOnlineLocationHandler; use wcf\system\user\signature\SignatureCache; @@ -23,7 +25,7 @@ use wcf\util\StringUtil; * Decorates the user object and provides functions to retrieve data for user profiles. * * @author Marcel Werk - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage data.user @@ -31,43 +33,43 @@ use wcf\util\StringUtil; */ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - protected static $baseClass = 'wcf\data\user\User'; + protected static $baseClass = User::class; /** * cached list of user profiles - * @var array<\wcf\data\user\UserProfile> + * @var UserProfile[] */ - protected static $userProfiles = array(); + protected static $userProfiles = []; /** * list of ignored user ids - * @var array + * @var integer[] */ protected $ignoredUserIDs = null; /** * list of follower user ids - * @var array + * @var integer[] */ protected $followerUserIDs = null; /** * list of following user ids - * @var array + * @var integer[] */ protected $followingUserIDs = null; /** * user avatar - * @var \wcf\data\user\avatar\IUserAvatar + * @var IUserAvatar */ protected $avatar = null; /** * user rank object - * @var \wcf\data\user\rank\UserRank + * @var UserRank */ protected $rank = null; @@ -98,7 +100,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider const ACCESS_NOBODY = 3; /** - * @see \wcf\data\user\User::__toString() + * @inheritDoc */ public function __toString() { return $this->getDecoratedObject()->__toString(); @@ -107,11 +109,11 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns a list of all user ids being followed by current user. * - * @return array + * @return integer[] */ public function getFollowingUsers() { if ($this->followingUserIDs === null) { - $this->followingUserIDs = array(); + $this->followingUserIDs = []; if ($this->userID) { // get ids @@ -123,7 +125,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider FROM wcf".WCF_N."_user_follow WHERE userID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->userID)); + $statement->execute([$this->userID]); while ($row = $statement->fetchArray()) { $this->followingUserIDs[] = $row['followUserID']; } @@ -143,11 +145,11 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns a list of user ids following current user. * - * @return array + * @return integer[] */ public function getFollowers() { if ($this->followerUserIDs === null) { - $this->followerUserIDs = array(); + $this->followerUserIDs = []; if ($this->userID) { // get ids @@ -159,7 +161,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider FROM wcf".WCF_N."_user_follow WHERE followUserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->userID)); + $statement->execute([$this->userID]); while ($row = $statement->fetchArray()) { $this->followerUserIDs[] = $row['userID']; } @@ -179,11 +181,11 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns a list of ignored user ids. * - * @return array + * @return integer[] */ public function getIgnoredUsers() { if ($this->ignoredUserIDs === null) { - $this->ignoredUserIDs = array(); + $this->ignoredUserIDs = []; if ($this->userID) { // get ids @@ -195,7 +197,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider FROM wcf".WCF_N."_user_ignore WHERE userID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->userID)); + $statement->execute([$this->userID]); while ($row = $statement->fetchArray()) { $this->ignoredUserIDs[] = $row['ignoreUserID']; } @@ -243,9 +245,9 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider } /** - * Gets the user's avatar. + * Returns the user's avatar. * - * @return \wcf\data\user\avatar\IUserAvatar + * @return IUserAvatar */ public function getAvatar() { if ($this->avatar === null) { @@ -319,10 +321,10 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider public function getCurrentLocation() { if ($this->currentLocation === null) { $this->currentLocation = ''; - $this->currentLocation = UserOnlineLocationHandler::getInstance()->getLocation(new UserOnline(new User(null, array( + $this->currentLocation = UserOnlineLocationHandler::getInstance()->getLocation(new UserOnline(new User(null, [ 'controller' => $this->controller, 'objectID' => $this->locationObjectID - )))); + ]))); } return $this->currentLocation; @@ -341,22 +343,22 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider * Returns a new user profile object. * * @param integer $userID - * @return \wcf\data\user\UserProfile - * @deprecated use UserProfileCache::getUserProfile() + * @return UserProfile + * @deprecated since 2.2, use UserProfileRuntimeCache::getObject() */ public static function getUserProfile($userID) { - return UserProfileCache::getInstance()->getUserProfile($userID); + return UserProfileRuntimeCache::getInstance()->getObject($userID); } /** * Returns a list of user profiles. * - * @param array $userIDs - * @return array<\wcf\data\user\UserProfile> - * @deprecated use UserProfileCache::getUserProfiles() + * @param integer[] $userIDs + * @return UserProfile[] + * @deprecated since 2.2, use UserProfileRuntimeCache::getObjects() */ public static function getUserProfiles(array $userIDs) { - $users = UserProfileCache::getInstance()->getUserProfiles($userIDs); + $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); // this method does not return null for non-existing user profiles foreach ($users as $userID => $user) { @@ -371,12 +373,11 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns the user profile of the user with the given name. * - * @param string $username - * @return \wcf\data\user\UserProfile - * @todo move to UserProfileCache? + * @param string $username + * @return UserProfile */ public static function getUserProfileByUsername($username) { - $users = self::getUserProfilesByUsername(array($username)); + $users = self::getUserProfilesByUsername([$username]); return $users[$username]; } @@ -384,15 +385,14 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns the user profiles of the users with the given names. * - * @param array $usernames - * @return array<\wcf\data\user\UserProfile> - * @todo move to UserProfileCache? + * @param string[] $usernames + * @return UserProfile[] */ public static function getUserProfilesByUsername(array $usernames) { - $users = array(); + $users = []; // save case sensitive usernames - $caseSensitiveUsernames = array(); + $caseSensitiveUsernames = []; foreach ($usernames as &$username) { $tmp = mb_strtolower($username); $caseSensitiveUsernames[$tmp] = $username; @@ -401,7 +401,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider unset($username); // check cache - $userProfiles = UserProfileCache::getInstance()->getCachedUserProfiles(); + $userProfiles = UserProfileRuntimeCache::getInstance()->getCachedObjects(); foreach ($usernames as $index => $username) { foreach ($userProfiles as $user) { if (mb_strtolower($user->username) === $username) { @@ -413,7 +413,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider if (!empty($usernames)) { $userList = new UserProfileList(); - $userList->getConditionBuilder()->add("user_table.username IN (?)", array($usernames)); + $userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]); $userList->readObjects(); foreach ($userList as $user) { @@ -576,13 +576,13 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider /** * Returns the user rank. * - * @return \wcf\data\user\rank\UserRank + * @return UserRank */ public function getRank() { if ($this->rank === null) { if (MODULE_USER_RANK && $this->rankID) { if ($this->rankTitle) { - $this->rank = new UserRank(null, array( + $this->rank = new UserRank(null, [ 'rankID' => $this->rankID, 'groupID' => $this->groupID, 'requiredPoints' => $this->requiredPoints, @@ -591,7 +591,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider 'rankImage' => $this->rankImage, 'repeatImage' => $this->repeatImage, 'requiredGender' => $this->requiredGender - )); + ]); } else { // load storage data @@ -618,7 +618,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider // get group data from cache $this->groupData = UserGroupPermissionCacheBuilder::getInstance()->getData($this->getGroupIDs()); if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $this->getGroupIDs()) { - $this->groupData = array(); + $this->groupData = []; } } @@ -647,12 +647,12 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider } /** - * @see \wcf\system\breadcrumb\IBreadcrumbProvider::getBreadcrumb() + * @inheritDoc */ public function getBreadcrumb() { - return new Breadcrumb($this->username, LinkHandler::getInstance()->getLink('User', array( + return new Breadcrumb($this->username, LinkHandler::getInstance()->getLink('User', [ 'object' => $this - ))); + ])); } /** @@ -787,7 +787,7 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider * @return string */ public function getAnchorTag() { - $link = LinkHandler::getInstance()->getLink('User', array('object' => $this->getDecoratedObject())); + $link = LinkHandler::getInstance()->getLink('User', ['object' => $this->getDecoratedObject()]); return ''.StringUtil::encodeHtml($this->username).''; } diff --git a/wcfsetup/install/files/lib/data/user/UserProfileCache.class.php b/wcfsetup/install/files/lib/data/user/UserProfileCache.class.php index c0ba5c39da..7eb0afa824 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfileCache.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfileCache.class.php @@ -1,5 +1,6 @@ - */ - protected $userIDs = array(); - - /** - * locally cached user profiles - * @var array<\wcf\data\user\UserProfile> - */ - protected $userProfiles = array(); - - /** - * Caches the given user id. - * - * @param integer $userID + * @see UserProfiltRuntimeCache::cacheObjectID() */ public function cacheUserID($userID) { - $this->userIDs[] = $userID; + UserProfileRuntimeCache::getInstance()->cacheObjectID($userID); } /** - * Caches the given user ids. - * - * @param array $userIDs + * @see UserProfiltRuntimeCache::cacheUserIDs() */ public function cacheUserIDs(array $userIDs) { - $this->userIDs = array_merge($this->userIDs, $userIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs); } /** - * Returns all currently cached user profile objects. - * - * @return array<\wcf\data\user\UserProfile> + * @see UserProfiltRuntimeCache::getCachedObjects() */ public function getCachedUserProfiles() { - return $this->userProfiles; + return UserProfileRuntimeCache::getInstance()->getCachedObjects(); } /** - * Returns the user profile of the user with the given user id. If no such - * user profile exists, null is returned. - * - * @param integer $userID - * @return \wcf\data\user\UserProfile + * @see UserProfiltRuntimeCache::getObject() */ public function getUserProfile($userID) { - if (array_key_exists($userID, $this->userProfiles)) { - return $this->userProfiles[$userID]; - } - - return $this->getUserProfiles(array($userID))[$userID]; + return UserProfileRuntimeCache::getInstance()->getObject($userID); } /** - * Returns the user profiles of the users with the given user ids. For ids - * without a user profile, null is returned. - * - * @param array $userIDs - * @return array<\wcf\data\user\UserProfile> + * @see UserProfiltRuntimeCache::getObjects() */ public function getUserProfiles(array $userIDs) { - $userProfiles = array(); - foreach ($userIDs as $key => $userID) { - if (array_key_exists($userID, $this->userProfiles)) { - $userProfiles[$userID] = $this->userProfiles[$userID]; - - unset($userIDs[$key]); - } - } - - if (empty($userIDs)) { - return $userProfiles; - } - - $this->userIDs = array_unique(array_merge($this->userIDs, $userIDs)); - - $userProfileList = new UserProfileList(); - $userProfileList->setObjectIDs($this->userIDs); - $userProfileList->readObjects(); - $readUserProfiles = $userProfileList->getObjects(); - - foreach ($this->userIDs as $userID) { - if (!isset($readUserProfiles[$userID])) { - $this->userProfiles[$userID] = null; - } - else { - $this->userProfiles[$userID] = $readUserProfiles[$userID]; - } - } - - $this->userIDs = array(); - - foreach ($userIDs as $userID) { - $userProfiles[$userID] = $this->userProfiles[$userID]; - } - - return $userProfiles; + return UserProfileRuntimeCache::getInstance()->getObjects($userIDs); } } diff --git a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEvent.class.php b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEvent.class.php index 19e6736ba0..4c1126b8ee 100644 --- a/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/data/user/activity/event/ViewableUserActivityEvent.class.php @@ -1,15 +1,15 @@ * @package com.woltlab.wcf * @subpackage data.user.activity.event @@ -17,9 +17,9 @@ use wcf\system\user\activity\event\UserActivityEventHandler; */ class ViewableUserActivityEvent extends DatabaseObjectDecorator { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - public static $baseClass = 'wcf\data\user\activity\event\UserActivityEvent'; + public static $baseClass = UserActivityEvent::class; /** * event text @@ -47,7 +47,7 @@ class ViewableUserActivityEvent extends DatabaseObjectDecorator { /** * user profile - * @var \wcf\data\user\UserProfile + * @var UserProfile */ protected $userProfile = null; @@ -86,7 +86,7 @@ class ViewableUserActivityEvent extends DatabaseObjectDecorator { /** * Sets user profile. * - * @param \wcf\data\user\UserProfile $userProfile + * @param UserProfile $userProfile */ public function setUserProfile(UserProfile $userProfile) { $this->userProfile = $userProfile; @@ -95,11 +95,11 @@ class ViewableUserActivityEvent extends DatabaseObjectDecorator { /** * Returns user profile. * - * @return \wcf\data\user\UserProfile + * @return UserProfile */ public function getUserProfile() { if ($this->userProfile === null) { - $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID); + $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID); } return $this->userProfile; 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 afdb5f3b38..4c1812abe6 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 @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage data.user.activity.event @@ -17,9 +17,9 @@ use wcf\system\WCF; */ class ViewableUserActivityEventList extends UserActivityEventList { /** - * @see \wcf\data\DatabaseObjectList::$className + * @inheritDoc */ - public $className = 'wcf\data\user\activity\event\UserActivityEvent'; + public $className = UserActivityEvent::class; /** * @see \wcf\data\DatabaseObjectList::$decoratorClassName @@ -27,43 +27,43 @@ class ViewableUserActivityEventList extends UserActivityEventList { public $decoratorClassName = ViewableUserActivityEvent::class; /** - * @see \wcf\data\DatabaseObjectList::$sqlLimit + * @inheritDoc */ public $sqlLimit = 20; /** - * @see \wcf\data\DatabaseObjectList::$sqlOrderBy + * @inheritDoc */ public $sqlOrderBy = 'user_activity_event.time DESC, user_activity_event.eventID DESC'; /** - * Creates a new ViewableUserActivityEventList object. + * @inheritDoc */ public function __construct() { parent::__construct(); if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) { - $this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs())); + $this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', [WCF::getUser()->getLanguageIDs()]); } } /** - * @see \wcf\data\DatabaseObjectList::readObjects() + * @inheritDoc */ public function readObjects() { parent::readObjects(); - $userIDs = array(); - $eventGroups = array(); + $userIDs = []; + $eventGroups = []; foreach ($this->objects as $event) { $userIDs[] = $event->userID; if (!isset($eventGroups[$event->objectTypeID])) { $objectType = UserActivityEventHandler::getInstance()->getObjectType($event->objectTypeID); - $eventGroups[$event->objectTypeID] = array( + $eventGroups[$event->objectTypeID] = [ 'className' => $objectType->className, - 'objects' => array() - ); + 'objects' => [] + ]; } $eventGroups[$event->objectTypeID]['objects'][] = $event; @@ -71,12 +71,12 @@ class ViewableUserActivityEventList extends UserActivityEventList { // set user profiles if (!empty($userIDs)) { - UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs)); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs)); } // parse events foreach ($eventGroups as $eventData) { - $eventClass = call_user_func(array($eventData['className'], 'getInstance')); + $eventClass = call_user_func([$eventData['className'], 'getInstance']); $eventClass->prepare($eventData['objects']); } } @@ -102,10 +102,10 @@ class ViewableUserActivityEventList extends UserActivityEventList { /** * Validates event permissions and returns a list of orphaned event ids. * - * @return array + * @return integer[] */ public function validateEvents() { - $orphanedEventIDs = array(); + $orphanedEventIDs = []; foreach ($this->objects as $index => $event) { if ($event->isOrphaned()) { diff --git a/wcfsetup/install/files/lib/system/cache/runtime/AbstractRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/AbstractRuntimeCache.class.php new file mode 100644 index 0000000000..4e237795ec --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/runtime/AbstractRuntimeCache.class.php @@ -0,0 +1,142 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.runtime + * @category Community Framework + * @since 2.2 + */ +abstract class AbstractRuntimeCache extends SingletonFactory implements IRuntimeCache { + /** + * name of the DatabaseObjectList class + * @var string + */ + protected $listClassName = ''; + + /** + * ids of objects which will be fetched next + * @var integer[] + */ + protected $objectIDs = []; + + /** + * cached DatabaseObject objects + * @var DatabaseObject[] + */ + protected $objects = []; + + /** + * @inheritDoc + */ + public function cacheObjectID($objectID) { + $this->cacheObjectIDs([$objectID]); + } + + /** + * @inheritDoc + */ + public function cacheObjectIDs(array $objectIDs) { + foreach ($objectIDs as $objectID) { + if (!array_key_exists($objectID, $this->objects) && !in_array($objectID, $this->objectIDs)) { + $this->objectIDs[] = $objectID; + } + } + } + + /** + * Fetches the objects for the pending object ids. + */ + protected function fetchObjects() { + /** @var DatabaseObjectList $objectList */ + $objectList = new $this->listClassName; + $objectList->setObjectIDs($this->objectIDs); + $objectList->readObjects(); + $this->objects += $objectList->getObjects(); + + // create null entries for non-existing objects + foreach ($this->objectIDs as $objectID) { + if (!array_key_exists($objectID, $this->objects)) { + $this->objects[$objectID] = null; + } + } + + $this->objectIDs = []; + } + + /** + * @inheritDoc + */ + public function getCachedObjects() { + return $this->objects; + } + + /** + * @inheritDoc + */ + public function getObject($objectID) { + if (array_key_exists($objectID, $this->objects)) { + return $this->objects[$objectID]; + } + + $this->cacheObjectID($objectID); + + $this->fetchObjects(); + + return $this->objects[$objectID]; + } + + /** + * @inheritDoc + */ + public function getObjects(array $objectIDs) { + $objects = []; + + // set already cached objects + foreach ($objectIDs as $key => $objectID) { + if (array_key_exists($objectID, $this->objects)) { + $objects[$objectID] = $this->objects[$objectID]; + unset($objectIDs[$key]); + } + } + + if (!empty($objectIDs)) { + $this->cacheObjectIDs($objectIDs); + + $this->fetchObjects(); + + // set newly loaded cached objects + foreach ($objectIDs as $objectID) { + $objects[$objectID] = $this->objects[$objectID]; + } + } + + return $objects; + } + + /** + * @inheritDoc + */ + public function removeObject($objectID) { + $this->removeObjects([$objectID]); + } + + /** + * @inheritDoc + */ + public function removeObjects(array $objectIDs){ + foreach ($objectIDs as $objectID) { + if (array_key_exists($objectID, $this->objects)) { + unset($this->objects[$objectID]); + } + } + } +} diff --git a/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php new file mode 100644 index 0000000000..18bf7e7641 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/runtime/CommentRuntimeCache.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.runtime + * @category Community Framework + * @since 2.2 + * + * @method Comment getObject($objectID) + * @method Comment[] getObjects(array $objectIDs) + */ +class CommentRuntimeCache extends AbstractRuntimeCache { + /** + * @inheritDoc + */ + protected $listClassName = CommentList::class; +} diff --git a/wcfsetup/install/files/lib/system/cache/runtime/IRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/IRuntimeCache.class.php new file mode 100644 index 0000000000..d81bc7e79b --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/runtime/IRuntimeCache.class.php @@ -0,0 +1,75 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.runtime + * @category Community Framework + * @since 2.2 + */ +interface IRuntimeCache { + /** + * Caches the given object id so that during the next object fetch, the object with + * this id will also be fetched. + * + * @param integer $objectID + */ + public function cacheObjectID($objectID); + + /** + * Caches the given object ids so that during the next object fetch, the objects with + * these ids will also be fetched. + * + * @param integer[] $objectIDs + */ + public function cacheObjectIDs(array $objectIDs); + + /** + * Returns all currently cached objects. + * + * @return DatabaseObject[] + */ + public function getCachedObjects(); + + /** + * Returns the object with the given id or null if no such object exists. + * If the given object id should not have been cached before, it will be cached + * during this method call and the object, if existing, will be returned. + * + * @param integer $objectID + * @return DatabaseObject|null + */ + public function getObject($objectID); + + /** + * Returns the objects with the given ids. If an object does not exist, the array element + * wil be null. + * If the given object ids should not have been cached before, they will be cached + * during this method call and the objects, if existing, will be returned. + * + * @param integer[] $objectIDs + * @return DatabaseObject[] + */ + public function getObjects(array $objectIDs); + + /** + * Removes the object with the given id from the runtime cache if it has already been loaded. + * + * @param integer $objectID + */ + public function removeObject($objectID); + + + /** + * Removes the objects with the given ids from the runtime cache if they have already been loaded. + * + * @param integer $objectID + */ + public function removeObjects(array $objectIDs); +} diff --git a/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php b/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php new file mode 100644 index 0000000000..1734fbb6ee --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/runtime/UserProfileRuntimeCache.class.php @@ -0,0 +1,25 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.runtime + * @category Community Framework + * @since 2.2 + * + * @method UserProfile getObject($objectID) + * @method UserProfile[] getObjects(array $objectIDs) + */ +class UserProfileRuntimeCache extends AbstractRuntimeCache { + /** + * @inheritDoc + */ + protected $listClassName = UserProfileList::class; +} diff --git a/wcfsetup/install/files/lib/system/comment/CommentDataHandler.class.php b/wcfsetup/install/files/lib/system/comment/CommentDataHandler.class.php index 627ff32ed0..df756a4973 100644 --- a/wcfsetup/install/files/lib/system/comment/CommentDataHandler.class.php +++ b/wcfsetup/install/files/lib/system/comment/CommentDataHandler.class.php @@ -1,98 +1,46 @@ * @package com.woltlab.wcf * @subpackage system.comment * @category Community Framework + * @deprecated since 2.2, use CommentRuntimeCache and UserProfileRuntimeCache */ class CommentDataHandler extends SingletonFactory { /** - * list of comment ids - * @var array - */ - protected $commentIDs = array(); - - /** - * list of cached comment objects - * @var array<\wcf\data\comment\Comment> - */ - protected $comments = array(); - - /** - * list of user ids - * @var array - */ - protected $userIDs = array(); - - /** - * Caches a comment id. - * - * @param integer $commentID + * @see CommentRuntimeCache::cacheObjectID() */ public function cacheCommentID($commentID) { - if (!in_array($commentID, $this->commentIDs)) { - $this->commentIDs[] = $commentID; - } + CommentRuntimeCache::getInstance()->cacheObjectID($commentID); } /** - * Caches a user id. - * - * @param integer $userID + * @see UserProfileRuntimeCache::cacheObjectID() */ public function cacheUserID($userID) { - if (!in_array($userID, $this->userIDs)) { - $this->userIDs[] = $userID; - } + UserProfileRuntimeCache::getInstance()->cacheObjectID($userID); } /** - * Returns a comment by id, fetches comments on first call. - * - * @param integer $commentID - * @return \wcf\data\comment\Comment + * @see CommentRuntimeCache::getComment() */ public function getComment($commentID) { - if (!empty($this->commentIDs)) { - $this->commentIDs = array_diff($this->commentIDs, array_keys($this->comments)); - - if (!empty($this->commentIDs)) { - $commentList = new CommentList(); - $commentList->setObjectIDs($this->commentIDs); - $commentList->readObjects(); - $this->comments += $commentList->getObjects(); - $this->commentIDs = array(); - } - } - - if (isset($this->comments[$commentID])) { - return $this->comments[$commentID]; - } - - return null; + return CommentRuntimeCache::getInstance()->getObject($commentID); } /** - * Returns a user profile by id, fetches user profiles on first call. - * - * @param integer $userID - * @return \wcf\data\user\UserProfile + * @see UserProfileRuntimeCache::getObject() */ public function getUser($userID) { - if (!empty($this->userIDs)) { - UserProfile::getUserProfiles($this->userIDs); - $this->userIDs = array(); - } - - return UserProfile::getUserProfile($userID); + return UserProfileRuntimeCache::getInstance()->getObject($userID); } } diff --git a/wcfsetup/install/files/lib/system/dashboard/box/MostActiveMembersDashboardBox.class.php b/wcfsetup/install/files/lib/system/dashboard/box/MostActiveMembersDashboardBox.class.php index 50895a1af3..692fb5612a 100644 --- a/wcfsetup/install/files/lib/system/dashboard/box/MostActiveMembersDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/box/MostActiveMembersDashboardBox.class.php @@ -1,10 +1,10 @@ * @package com.woltlab.wcf * @subpackage system.dashboard.box @@ -21,12 +21,12 @@ use wcf\system\WCF; class MostActiveMembersDashboardBox extends AbstractSidebarDashboardBox { /** * ids of the most active members - * @var array + * @var integer[] */ - public $mostActiveMemberIDs = array(); + public $mostActiveMemberIDs = []; /** - * @see \wcf\system\dashboard\box\AbstractDashboardBoxContent::init() + * @inheritDoc */ public function init(DashboardBox $box, IPage $page) { parent::init($box, $page); @@ -34,28 +34,28 @@ class MostActiveMembersDashboardBox extends AbstractSidebarDashboardBox { // get ids $this->mostActiveMemberIDs = MostActiveMembersCacheBuilder::getInstance()->getData(); if (!empty($this->mostActiveMemberIDs)) { - UserProfileCache::getInstance()->cacheUserIDs($this->mostActiveMemberIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->mostActiveMemberIDs); } $this->fetched(); } /** - * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render() + * @inheritDoc */ protected function render() { if (empty($this->mostActiveMemberIDs)) return ''; if (MODULE_MEMBERS_LIST) { - $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=activityPoints&sortOrder=DESC'); + $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=activityPoints&sortOrder=DESC'); } - $mostActiveMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostActiveMemberIDs); + $mostActiveMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->mostActiveMemberIDs); DatabaseObject::sort($mostActiveMembers, 'activityPoints', 'DESC'); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'mostActiveMembers' => $mostActiveMembers - )); + ]); return WCF::getTPL()->fetch('dashboardBoxMostActiveMembers'); } } diff --git a/wcfsetup/install/files/lib/system/dashboard/box/MostLikedMembersDashboardBox.class.php b/wcfsetup/install/files/lib/system/dashboard/box/MostLikedMembersDashboardBox.class.php index fa80d6ad91..997651863c 100644 --- a/wcfsetup/install/files/lib/system/dashboard/box/MostLikedMembersDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/box/MostLikedMembersDashboardBox.class.php @@ -1,10 +1,10 @@ * @package com.woltlab.wcf * @subpackage system.dashboard.box @@ -21,12 +21,12 @@ use wcf\system\WCF; class MostLikedMembersDashboardBox extends AbstractSidebarDashboardBox { /** * ids of the most liked members - * @var array + * @var integer[] */ - public $mostLikedMemberIDs = array(); + public $mostLikedMemberIDs = []; /** - * @see \wcf\system\dashboard\box\IDashboardBox::init() + * @inheritDoc */ public function init(DashboardBox $box, IPage $page) { parent::init($box, $page); @@ -37,26 +37,26 @@ class MostLikedMembersDashboardBox extends AbstractSidebarDashboardBox { $this->fetched(); if (!empty($this->mostLikedMemberIDs)) { - UserProfileCache::getInstance()->cacheUserIDs($this->mostLikedMemberIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->mostLikedMemberIDs); } } /** - * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render() + * @inheritDoc */ protected function render() { if (empty($this->mostLikedMemberIDs)) return ''; if (MODULE_MEMBERS_LIST) { - $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=likesReceived&sortOrder=DESC'); + $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=likesReceived&sortOrder=DESC'); } - $mostLikedMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostLikedMemberIDs); + $mostLikedMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->mostLikedMemberIDs); DatabaseObject::sort($mostLikedMembers, 'likesReceived', 'DESC'); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'mostLikedMembers' => $mostLikedMembers - )); + ]); return WCF::getTPL()->fetch('dashboardBoxMostLikedMembers'); } } diff --git a/wcfsetup/install/files/lib/system/dashboard/box/NewestMembersDashboardBox.class.php b/wcfsetup/install/files/lib/system/dashboard/box/NewestMembersDashboardBox.class.php index 2d807c3525..a304fe0fa2 100644 --- a/wcfsetup/install/files/lib/system/dashboard/box/NewestMembersDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/box/NewestMembersDashboardBox.class.php @@ -1,10 +1,10 @@ * @package com.woltlab.wcf * @subpackage system.dashboard.box @@ -21,12 +21,12 @@ use wcf\system\WCF; class NewestMembersDashboardBox extends AbstractSidebarDashboardBox { /** * ids of the newest members - * @var array + * @var integer[] */ - public $newestMemberIDs = array(); + public $newestMemberIDs = []; /** - * @see \wcf\system\dashboard\box\IDashboardBox::init() + * @inheritDoc */ public function init(DashboardBox $box, IPage $page) { parent::init($box, $page); @@ -34,28 +34,28 @@ class NewestMembersDashboardBox extends AbstractSidebarDashboardBox { // get ids $this->newestMemberIDs = NewestMembersCacheBuilder::getInstance()->getData(); if (!empty($this->newestMemberIDs)) { - UserProfileCache::getInstance()->cacheUserIDs($this->newestMemberIDs); + UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->newestMemberIDs); } $this->fetched(); } /** - * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render() + * @inheritDoc */ protected function render() { if (empty($this->newestMemberIDs)) return ''; if (MODULE_MEMBERS_LIST) { - $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=registrationDate&sortOrder=DESC'); + $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=registrationDate&sortOrder=DESC'); } - $newestMembers = UserProfileCache::getInstance()->getUserProfiles($this->newestMemberIDs); + $newestMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->newestMemberIDs); DatabaseObject::sort($newestMembers, 'registrationDate', 'DESC'); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'newestMembers' => $newestMembers - )); + ]); return WCF::getTPL()->fetch('dashboardBoxNewestMembers'); } } diff --git a/wcfsetup/install/files/lib/system/dashboard/box/TodaysBirthdaysDashboardBox.class.php b/wcfsetup/install/files/lib/system/dashboard/box/TodaysBirthdaysDashboardBox.class.php index 3b6976e5b6..36256735aa 100644 --- a/wcfsetup/install/files/lib/system/dashboard/box/TodaysBirthdaysDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/box/TodaysBirthdaysDashboardBox.class.php @@ -1,9 +1,10 @@ * @package com.woltlab.wcf * @subpackage system.dashboard.box @@ -21,12 +22,12 @@ use wcf\util\DateUtil; class TodaysBirthdaysDashboardBox extends AbstractSidebarDashboardBox { /** * user profiles - * @var array<\wcf\data\user\UserProfile> + * @var UserProfile[] */ - public $userProfiles = array(); + public $userProfiles = []; /** - * @see \wcf\system\dashboard\box\IDashboardBox::init() + * @inheritDoc */ public function init(DashboardBox $box, IPage $page) { parent::init($box, $page); @@ -39,11 +40,11 @@ class TodaysBirthdaysDashboardBox extends AbstractSidebarDashboardBox { $userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]); if (!empty($userIDs)) { - $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options'); + $userOptions = UserOptionCacheBuilder::getInstance()->getData([], 'options'); if (isset($userOptions['birthday'])) { $birthdayUserOption = $userOptions['birthday']; - $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs); + $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); $i = 0; foreach ($userProfiles as $userProfile) { @@ -63,16 +64,16 @@ class TodaysBirthdaysDashboardBox extends AbstractSidebarDashboardBox { } /** - * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render() + * @inheritDoc */ protected function render() { if (empty($this->userProfiles)) { return ''; } - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'birthdayUserProfiles' => $this->userProfiles - )); + ]); return WCF::getTPL()->fetch('dashboardBoxTodaysBirthdays'); } } diff --git a/wcfsetup/install/files/lib/system/dashboard/box/TodaysFollowingBirthdaysDashboardBox.class.php b/wcfsetup/install/files/lib/system/dashboard/box/TodaysFollowingBirthdaysDashboardBox.class.php index f9867464ef..6061e644b9 100644 --- a/wcfsetup/install/files/lib/system/dashboard/box/TodaysFollowingBirthdaysDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/dashboard/box/TodaysFollowingBirthdaysDashboardBox.class.php @@ -2,8 +2,8 @@ namespace wcf\system\dashboard\box; use wcf\data\dashboard\box\DashboardBox; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; use wcf\page\IPage; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\user\UserBirthdayCache; use wcf\system\WCF; use wcf\util\DateUtil; @@ -12,7 +12,7 @@ use wcf\util\DateUtil; * Shows today's birthdays of users the active user is following. * * @author Marcel Werk - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.dashboard.box @@ -40,7 +40,7 @@ class TodaysFollowingBirthdaysDashboardBox extends AbstractSidebarDashboardBox { $userIDs = array_intersect($userIDs, WCF::getUserProfileHandler()->getFollowingUsers()); if (!empty($userIDs)) { - $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs); + $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); $i = 0; foreach ($userProfiles as $userProfile) { diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php index d29a499a97..96eb48763c 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php @@ -1,7 +1,7 @@ userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIds); + $this->userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIds); } } diff --git a/wcfsetup/install/files/lib/system/message/embedded/object/QuoteMessageEmbeddedObjectHandler.class.php b/wcfsetup/install/files/lib/system/message/embedded/object/QuoteMessageEmbeddedObjectHandler.class.php index ce7d2d7ff2..905b966987 100644 --- a/wcfsetup/install/files/lib/system/message/embedded/object/QuoteMessageEmbeddedObjectHandler.class.php +++ b/wcfsetup/install/files/lib/system/message/embedded/object/QuoteMessageEmbeddedObjectHandler.class.php @@ -1,13 +1,13 @@ * @package com.woltlab.wcf * @subpackage system.message.embedded.object @@ -15,13 +15,13 @@ use wcf\data\user\UserProfileCache; */ class QuoteMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler { /** - * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::parseMessage() + * @inheritDoc */ public function parseMessage($message) { $usernames = self::getFirstParameters($message, 'quote'); if (!empty($usernames)) { $userList = new UserList(); - $userList->getConditionBuilder()->add("user_table.username IN (?)", array($usernames)); + $userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]); $userList->readObjectIDs(); return $userList->getObjectIDs(); } @@ -30,9 +30,9 @@ class QuoteMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHan } /** - * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::loadObjects() + * @inheritDoc */ public function loadObjects(array $objectIDs) { - return UserProfileCache::getInstance()->getUserProfiles($objectIDs); + return UserProfileRuntimeCache::getInstance()->getObjects($objectIDs); } } diff --git a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php index 5e2e2a3fa9..a683fbe6a0 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentResponseUserActivityEvent.class.php @@ -2,7 +2,7 @@ namespace wcf\system\user\activity\event; use wcf\data\comment\response\CommentResponseList; use wcf\data\comment\CommentList; -use wcf\data\user\UserProfileCache; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\SingletonFactory; use wcf\system\WCF; @@ -10,7 +10,7 @@ use wcf\system\WCF; * User activity event implementation for profile comment responses. * * @author Marcel Werk - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.user.activity.event @@ -18,14 +18,14 @@ use wcf\system\WCF; */ class ProfileCommentResponseUserActivityEvent extends SingletonFactory implements IUserActivityEvent { /** - * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare() + * @inheritDoc */ public function prepare(array $events) { if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) { return; } - $responses = $responseIDs = array(); + $responses = $responseIDs = []; foreach ($events as $event) { $responseIDs[] = $event->objectID; } @@ -37,7 +37,7 @@ class ProfileCommentResponseUserActivityEvent extends SingletonFactory implement $responses = $responseList->getObjects(); // fetch comments - $commentIDs = $comments = array(); + $commentIDs = $comments = []; foreach ($responses as $response) { $commentIDs[] = $response->commentID; } @@ -49,13 +49,13 @@ class ProfileCommentResponseUserActivityEvent extends SingletonFactory implement } // fetch users - $userIDs = $users = array(); + $userIDs = $users = []; foreach ($comments as $comment) { $userIDs[] = $comment->objectID; $userIDs[] = $comment->userID; } if (!empty($userIDs)) { - $users = UserProfileCache::getInstance()->getUserProfiles($userIDs); + $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); } // set message @@ -68,10 +68,10 @@ class ProfileCommentResponseUserActivityEvent extends SingletonFactory implement $event->setIsAccessible(); // title - $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', array( + $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', [ 'commentAuthor' => $users[$comment->userID], 'user' => $users[$comment->objectID] - )); + ]); $event->setTitle($text); // description diff --git a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentUserActivityEvent.class.php index c94fbe8c32..9c47e732d8 100644 --- a/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentUserActivityEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/event/ProfileCommentUserActivityEvent.class.php @@ -1,7 +1,7 @@ * @package com.woltlab.wcf * @subpackage system.user.activity.event @@ -17,7 +17,7 @@ use wcf\system\WCF; */ class ProfileCommentUserActivityEvent extends SingletonFactory implements IUserActivityEvent { /** - * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare() + * @inheritDoc */ public function prepare(array $events) { if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) { @@ -41,7 +41,7 @@ class ProfileCommentUserActivityEvent extends SingletonFactory implements IUserA $userIDs[] = $comment->objectID; } if (!empty($userIDs)) { - $users = UserProfileCache::getInstance()->getUserProfiles($userIDs); + $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs); } // set message diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php index d93b5c45e4..d48413a6f9 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php @@ -3,7 +3,9 @@ namespace wcf\system\user\notification\event; use wcf\data\user\User; use wcf\data\moderation\queue\ViewableModerationQueue; use wcf\data\object\type\ObjectTypeCache; -use wcf\system\comment\CommentDataHandler; +use wcf\data\user\UserProfile; +use wcf\system\cache\runtime\CommentRuntimeCache; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\moderation\queue\report\IModerationQueueReportHandler; use wcf\system\WCF; @@ -75,14 +77,14 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractShared ]); } - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); + $comment = CommentRuntimeCache::getInstance()->getComment($this->userNotificationObject->commentID); if ($comment->userID) { - $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID); + $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID); } else { - $commentAuthor = new User(null, [ + $commentAuthor = new UserProfile(new User(null, [ 'username' => $comment->username - ]); + ])); } return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.mail', [ @@ -127,14 +129,14 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractShared ]); } - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); if ($comment->userID) { - $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID); + $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID); } else { - $commentAuthor = new User(null, [ + $commentAuthor = new UserProfile(new User(null, [ 'username' => $comment->username - ]); + ])); } return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.message', [ @@ -152,7 +154,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractShared */ public function getModerationQueue() { if (!$this->moderationQueueLoaded) { - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($comment->objectID); $this->moderationQueueLoaded = true; @@ -195,7 +197,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractShared * @inheritDoc */ protected function prepare() { - CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID); - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']); + CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']); } } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php index 649b21e8c6..581e97a542 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentLikeUserNotificationEvent.class.php @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.user.notification.event @@ -16,87 +16,87 @@ use wcf\system\WCF; */ class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable + * @inheritDoc */ protected $stackable = true; /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare() + * @inheritDoc */ protected function prepare() { - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle() + * @inheritDoc */ public function getTitle() { $count = count($this->getAuthors()); if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', [ 'count' => $count, 'timesTriggered' => $this->notification->timesTriggered - )); + ]); } return $this->getLanguage()->get('wcf.user.notification.comment.like.title'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage() + * @inheritDoc */ public function getMessage() { $authors = array_values($this->getAuthors()); $count = count($authors); $owner = null; if ($this->additionalData['objectID'] != WCF::getUser()->userID) { - $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']); + $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']); } if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', [ 'author' => $this->author, 'authors' => $authors, 'count' => $count, 'others' => $count - 1, 'owner' => $owner - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [ 'author' => $this->author, 'owner' => $owner - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage() + * @inheritDoc */ - public function getEmailMessage($notificationType = 'instant') { /* not supported */ } + public function getEmailMessage($notificationType = 'instant') { + // not supported + } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink() + * @inheritDoc */ public function getLink() { $owner = WCF::getUser(); if ($this->additionalData['objectID'] != WCF::getUser()->userID) { - $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']); + $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']); } - return LinkHandler::getInstance()->getLink('User', array( - 'object' => $owner - ), '#wall'); + return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash() + * @inheritDoc */ public function getEventHash() { return sha1($this->eventID . '-' . $this->additionalData['objectID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification() + * @inheritDoc */ public function supportsEmailNotification() { return false; diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php index aa25716ddb..980375f15f 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseLikeUserNotificationEvent.class.php @@ -1,6 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.user.notification.event @@ -16,92 +16,92 @@ use wcf\system\WCF; */ class UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable + * @inheritDoc */ protected $stackable = true; /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare() + * @inheritDoc */ protected function prepare() { - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']); - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['commentUserID']); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle() + * @inheritDoc */ public function getTitle() { $count = count($this->getAuthors()); if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', [ 'count' => $count, 'timesTriggered' => $this->notification->timesTriggered - )); + ]); } return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage() + * @inheritDoc */ public function getMessage() { $authors = array_values($this->getAuthors()); $count = count($authors); $commentUser = $owner = null; if ($this->additionalData['objectID'] != WCF::getUser()->userID) { - $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']); + $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']); } if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) { - $commentUser = CommentDataHandler::getInstance()->getUser($this->additionalData['commentUserID']); + $commentUser = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']); } if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', [ 'author' => $this->author, 'authors' => $authors, 'commentUser' => $commentUser, 'count' => $count, 'others' => $count - 1, 'owner' => $owner - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [ 'author' => $this->author, 'owner' => $owner - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage() + * @inheritDoc */ - public function getEmailMessage($notificationType = 'instant') { /* not supported */ } + public function getEmailMessage($notificationType = 'instant') { + // not supported + } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink() + * @inheritDoc */ public function getLink() { $owner = WCF::getUser(); if ($this->additionalData['objectID'] != WCF::getUser()->userID) { - $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']); + $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']); } - return LinkHandler::getInstance()->getLink('User', array( - 'object' => $owner - ), '#wall'); + return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash() + * @inheritDoc */ public function getEventHash() { return sha1($this->eventID . '-' . $this->additionalData['commentID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification() + * @inheritDoc */ public function supportsEmailNotification() { return false; diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php index 2871ee23d1..da1c68cfee 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseOwnerUserNotificationEvent.class.php @@ -2,7 +2,9 @@ namespace wcf\system\user\notification\event; use wcf\data\comment\Comment; use wcf\data\user\User; -use wcf\system\comment\CommentDataHandler; +use wcf\data\user\UserProfile; +use wcf\system\cache\runtime\CommentRuntimeCache; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\request\LinkHandler; use wcf\system\WCF; @@ -10,7 +12,7 @@ use wcf\system\WCF; * User notification event for profile's owner for commment responses. * * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH + * @copyright 2001-2016 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.user.notification.event @@ -18,45 +20,45 @@ use wcf\system\WCF; */ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable + * @inheritDoc */ protected $stackable = true; /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare() + * @inheritDoc */ protected function prepare() { - CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID); - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']); + CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle() + * @inheritDoc */ public function getTitle() { $count = count($this->getAuthors()); if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [ 'count' => $count, 'timesTriggered' => $this->notification->timesTriggered - )); + ]); } return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage() + * @inheritDoc */ public function getMessage() { - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); if ($comment->userID) { - $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID); + $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID); } else { - $commentAuthor = new User(null, array( + $commentAuthor = new UserProfile(new User(null, [ 'username' => $comment->username - )); + ])); } $authors = $this->getAuthors(); @@ -66,23 +68,23 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare } $count = count($authors); - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [ 'author' => $commentAuthor, 'authors' => array_values($authors), 'count' => $count, 'others' => $count - 1, 'guestTimesTriggered' => $this->notification->guestTimesTriggered - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [ 'author' => $this->author, 'commentAuthor' => $commentAuthor - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage() + * @inheritDoc */ public function getEmailMessage($notificationType = 'instant') { $comment = new Comment($this->userNotificationObject->commentID); @@ -91,9 +93,9 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare $commentAuthor = new User($comment->userID); } else { - $commentAuthor = new User(null, array( + $commentAuthor = new User(null, [ 'username' => $comment->username - )); + ]); } $authors = $this->getAuthors(); @@ -103,7 +105,7 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare } $count = count($authors); - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', [ 'author' => $this->author, 'authors' => array_values($authors), 'commentAuthor' => $commentAuthor, @@ -113,27 +115,27 @@ class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractShare 'owner' => $owner, 'response' => $this->userNotificationObject, 'guestTimesTriggered' => $this->notification->guestTimesTriggered - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', [ 'response' => $this->userNotificationObject, 'author' => $this->author, 'commentAuthor' => $commentAuthor, 'owner' => $owner, 'notificationType' => $notificationType - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink() + * @inheritDoc */ public function getLink() { - return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall'); + return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash() + * @inheritDoc */ public function getEventHash() { return sha1($this->eventID . '-' . $this->userNotificationObject->commentID); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php index 82da3bb3da..1a60438544 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentResponseUserNotificationEvent.class.php @@ -1,13 +1,14 @@ * @package com.woltlab.wcf * @subpackage system.user.notification.event @@ -15,40 +16,40 @@ use wcf\system\request\LinkHandler; */ class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent { /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable + * @inheritDoc */ protected $stackable = true; /** - * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare() + * @inheritDoc */ protected function prepare() { - CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID); - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']); - CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']); + CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']); + UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle() + * @inheritDoc */ public function getTitle() { $count = count($this->getAuthors()); if ($count > 1) { - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [ 'count' => $count, 'timesTriggered' => $this->notification->timesTriggered - )); + ]); } return $this->getLanguage()->get('wcf.user.notification.commentResponse.title'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage() + * @inheritDoc */ public function getMessage() { - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); - $owner = CommentDataHandler::getInstance()->getUser($comment->objectID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); + $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID); $authors = $this->getAuthors(); if (count($authors) > 1) { @@ -57,27 +58,27 @@ class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUser } $count = count($authors); - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [ 'authors' => array_values($authors), 'count' => $count, 'others' => $count - 1, 'owner' => $owner, 'guestTimesTriggered' => $this->notification->guestTimesTriggered - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [ 'author' => $this->author, 'owner' => $owner - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage() + * @inheritDoc */ public function getEmailMessage($notificationType = 'instant') { - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); - $owner = CommentDataHandler::getInstance()->getUser($comment->objectID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); + $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID); $authors = $this->getAuthors(); if (count($authors) > 1) { @@ -86,7 +87,7 @@ class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUser } $count = count($authors); - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', [ 'author' => $this->author, 'authors' => array_values($authors), 'count' => $count, @@ -95,29 +96,29 @@ class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUser 'owner' => $owner, 'response' => $this->userNotificationObject, 'guestTimesTriggered' => $this->notification->guestTimesTriggered - )); + ]); } - return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array( + return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', [ 'response' => $this->userNotificationObject, 'author' => $this->author, 'owner' => $owner, 'notificationType' => $notificationType - )); + ]); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink() + * @inheritDoc */ public function getLink() { - $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID); - $user = CommentDataHandler::getInstance()->getUser($comment->objectID); + $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID); + $user = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID); - return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall'); + return LinkHandler::getInstance()->getLink('User', ['object' => $user], '#wall'); } /** - * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash() + * @inheritDoc */ public function getEventHash() { return sha1($this->eventID . '-' . $this->userNotificationObject->commentID); diff --git a/wcfsetup/install/files/lib/system/user/notification/object/type/TMultiRecipientModerationQueueCommentUserNotificationObjectType.class.php b/wcfsetup/install/files/lib/system/user/notification/object/type/TMultiRecipientModerationQueueCommentUserNotificationObjectType.class.php index 9500f58918..884dc21266 100644 --- a/wcfsetup/install/files/lib/system/user/notification/object/type/TMultiRecipientModerationQueueCommentUserNotificationObjectType.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/object/type/TMultiRecipientModerationQueueCommentUserNotificationObjectType.class.php @@ -2,7 +2,7 @@ namespace wcf\system\user\notification\object\type; use wcf\data\comment\Comment; use wcf\data\user\UserProfile; -use wcf\data\user\UserProfileCache; +use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\comment\CommentHandler; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\user\storage\UserStorageHandler; @@ -89,7 +89,7 @@ trait TMultiRecipientModerationQueueCommentUserNotificationObjectType { // make sure that all users (still) have permission to access moderation if (!$recipientIDs) { UserStorageHandler::getInstance()->loadStorage($recipientIDs); - $userProfiles = UserProfileCache::getInstance()->getUserProfiles($recipientIDs); + $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($recipientIDs); $recipientIDs = array_keys(array_filter($userProfiles, function(UserProfile $userProfile) { return $userProfile->getPermission('mod.general.canUseModeration'); })); -- 2.20.1