### 2.2.0 Alpha 1 (XXXX-YY-ZZ)
+* `wcf\data\user\UserProfileCache` for caching user profiles during runtime.
* instruction file name for most PIPs has default value provided by `wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename()`.
* `options` support for cronjobs.
* `name` attribute for cronjob PIP (`cronjobName` for cronjob objects).
--- /dev/null
+<?php
+namespace wcf\data;
+
+/**
+ * Provides legacy access to the properties of the related user profile object.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.user
+ * @category Community Framework
+ * @deprecated
+ */
+trait TLegacyUserPropertyAccess {
+ /**
+ * @see \wcf\data\IStorableObject::__get()
+ */
+ public function __get($name) {
+ $value = parent::__get($name);
+ if ($value !== null) {
+ return $value;
+ }
+ else if (!($this instanceof DatabaseObjectDecorator) && array_key_exists($name, $this->data)) {
+ return null;
+ }
+ else if ($this instanceof DatabaseObjectDecorator && array_key_exists($name, $this->object->data)) {
+ return null;
+ }
+
+ // in case any code should rely on directly accessing user properties,
+ // refer them to the user profile object
+ return $this->getUserProfile()->$name;
+ }
+}
$comment->setIsDeletable($this->commentProcessor->canDeleteComment($comment->getDecoratedObject()));
$comment->setIsEditable($this->commentProcessor->canEditComment($comment->getDecoratedObject()));
- // set user profile
- if ($comment->userID) {
- $userProfile = UserProfile::getUserProfile($comment->userID);
- $comment->setUserProfile($userProfile);
- }
-
WCF::getTPL()->assign(array(
'commentList' => array($comment),
'commentManager' => $this->commentProcessor
$response->setIsDeletable($this->commentProcessor->canDeleteResponse($response->getDecoratedObject()));
$response->setIsEditable($this->commentProcessor->canEditResponse($response->getDecoratedObject()));
- // set user profile
- if ($response->userID) {
- $userProfile = UserProfile::getUserProfile($response->userID);
- $response->setUserProfile($userProfile);
- }
-
// render response
WCF::getTPL()->assign(array(
'responseList' => array($response),
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;
/**
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = new UserProfile(new User(null, $this->data));
+ if ($this->userID) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+ else {
+ $this->userProfile = new UserProfile(new User(null, array(
+ 'username' => $this->username
+ )));
+ }
}
return $this->userProfile;
namespace wcf\data\comment;
use wcf\data\comment\response\CommentResponseList;
use wcf\data\comment\response\StructuredCommentResponse;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\like\LikeHandler;
}
}
- // fetch user data and avatars
+ // cache user ids
if (!empty($userIDs)) {
- $userIDs = array_unique($userIDs);
-
- $users = UserProfile::getUserProfiles($userIDs);
- foreach ($this->objects as $comment) {
- if ($comment->userID && isset($users[$comment->userID])) {
- $comment->setUserProfile($users[$comment->userID]);
- }
-
- foreach ($comment as $response) {
- if ($response->userID && isset($users[$response->userID])) {
- $response->setUserProfile($users[$response->userID]);
- }
- }
- }
+ UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
}
}
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;
/**
* Represents a viewable comment.
* @category Community Framework
*/
class ViewableComment extends DatabaseObjectDecorator {
+ use TLegacyUserPropertyAccess;
+
/**
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
*/
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = new UserProfile(new User(null, $this->getDecoratedObject()->data));
+ if ($this->userID) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+ else {
+ $this->userProfile = new UserProfile(new User(null, array(
+ 'username' => $this->username
+ )));
+ }
}
return $this->userProfile;
<?php
namespace wcf\data\comment;
+use wcf\data\user\UserProfileCache;
/**
* Represents a list of decorated comment objects.
*/
public $decoratorClassName = 'wcf\data\comment\ViewableComment';
- /**
- * Creates a new ViewableCommentList object.
- */
- public function __construct() {
- parent::__construct();
+ public function readObjects() {
+ parent::readObjects();
- // get avatars
- if (!empty($this->sqlSelects)) $this->sqlSelects .= ',';
- $this->sqlSelects .= "user_avatar.*, user_table.*";
- $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = comment.userID)";
- $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
+ if (!empty($this->objects)) {
+ $userIDs = array();
+ foreach ($this->objects as $comment) {
+ if ($comment->userID) {
+ $userIDs[] = $comment->userID;
+ }
+ }
+
+ if (!empty($userIDs)) {
+ UserProfileCache::getInstance()->cacheUserIDs($userIDs);
+ }
+ }
}
}
namespace wcf\data\comment\response;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
/**
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = new UserProfile(new User(null, $this->data));
+ if ($this->userID) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+ else {
+ $this->userProfile = new UserProfile(new User(null, array(
+ 'username' => $this->username
+ )));
+ }
}
return $this->userProfile;
// prepare structured response
$response = new StructuredCommentResponse($response);
- // add user profile
- $userProfile = UserProfile::getUserProfile($response->userID);
- $response->setUserProfile($userProfile);
+ // cache user profile
+ if ($response->userID) {
+ UserProfileCache::getInstance()->cacheUserID($response->userID);
+ }
return $response;
}
<?php
namespace wcf\data\comment\response;
use wcf\data\comment\Comment;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\like\LikeHandler;
$response->setIsEditable($this->commentManager->canEditResponse($response->getDecoratedObject()));
}
- // fetch user data and avatars
+ // cache user ids
if (!empty($userIDs)) {
- $userIDs = array_unique($userIDs);
-
- $users = UserProfile::getUserProfiles($userIDs);
- foreach ($this->objects as $response) {
- if (isset($users[$response->userID])) {
- $response->setUserProfile($users[$response->userID]);
- }
- }
+ UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
}
}
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;
/**
* Represents a viewable comment response.
* @category Community Framework
*/
class ViewableCommentResponse extends DatabaseObjectDecorator {
+ use TLegacyUserPropertyAccess;
+
/**
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
*/
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = new UserProfile(new User(null, $this->getDecoratedObject()->data));
+ if ($this->userID) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+ else {
+ $this->userProfile = new UserProfile(new User(null, array(
+ 'username' => $this->username
+ )));
+ }
}
return $this->userProfile;
<?php
namespace wcf\data\comment\response;
+use wcf\data\user\UserProfileCache;
/**
* Represents a list of decorated comment response objects.
* @see \wcf\data\DatabaseObjectList::$decoratorClassName
*/
public $decoratorClassName = 'wcf\data\comment\response\ViewableCommentResponse';
-
- /**
- * Creates a new ViewableCommentResponseList object.
- */
- public function __construct() {
- parent::__construct();
- // get avatars
- if (!empty($this->sqlSelects)) $this->sqlSelects .= ',';
- $this->sqlSelects .= "user_avatar.*, user_table.*";
- $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = comment_response.userID)";
- $this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user_avatar user_avatar ON (user_avatar.avatarID = user_table.avatarID)";
+ public function readObjects() {
+ parent::readObjects();
+
+ if (!empty($this->objects)) {
+ $userIDs = array();
+ foreach ($this->objects as $response) {
+ if ($response->userID) {
+ $userIDs[] = $response->userID;
+ }
+ }
+
+ if (!empty($userIDs)) {
+ UserProfileCache::getInstance()->cacheUserIDs($userIDs);
+ }
+ }
}
}
namespace wcf\data\like;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
/**
* @return \wcf\data\user\UserProfile
*/
public function getUserProfile() {
+ if ($this->userProfile === null) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+
return $this->userProfile;
}
<?php
namespace wcf\data\like;
use wcf\data\object\type\ObjectTypeCache;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\system\like\IViewableLikeProvider;
/**
// set user profiles
if (!empty($userIDs)) {
- $userIDs = array_unique($userIDs);
-
- $users = UserProfile::getUserProfiles($userIDs);
- foreach ($this->objects as $like) {
- $like->setUserProfile($users[$like->userID]);
- }
+ UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
}
// parse like
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\IUserContent;
use wcf\system\moderation\queue\ModerationQueueManager;
public function getUserProfile() {
if ($this->affectedObject !== null && $this->userProfile === null) {
if ($this->affectedObject->getUserID()) {
- $this->userProfile = UserProfile::getUserProfile($this->affectedObject->getUserID());
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->affectedObject->getUserID());
}
else {
$this->userProfile = new UserProfile(new User(null, array()));
<?php
namespace wcf\data\moderation\queue;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\WCF;
$userIDs[] = $object->getAffectedObject()->getUserID();
}
- $userProfiles = UserProfile::getUserProfiles($userIDs);
- foreach ($this->objects as $object) {
- if (isset($userProfiles[$object->getAffectedObject()->getUserID()])) {
- $object->setUserProfile($userProfiles[$object->getAffectedObject()->getUserID()]);
- }
- }
+ UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
}
}
}
*
* @param integer $userID
* @return \wcf\data\user\UserProfile
+ * @deprecated use UserProfileCache::getUserProfile()
*/
public static function getUserProfile($userID) {
- $users = self::getUserProfiles(array($userID));
-
- return (isset($users[$userID]) ? $users[$userID] : null);
+ return UserProfileCache::getInstance()->getUserProfile($userID);
}
/**
*
* @param array $userIDs
* @return array<\wcf\data\user\UserProfile>
+ * @deprecated use UserProfileCache::getUserProfiles()
*/
public static function getUserProfiles(array $userIDs) {
- $users = array();
-
- // check cache
- foreach ($userIDs as $index => $userID) {
- if (isset(self::$userProfiles[$userID])) {
- $users[$userID] = self::$userProfiles[$userID];
- unset($userIDs[$index]);
- }
- }
+ $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
- if (!empty($userIDs)) {
- $userList = new UserProfileList();
- $userList->setObjectIDs($userIDs);
- $userList->readObjects();
-
- foreach ($userList as $user) {
- $users[$user->userID] = $user;
- self::$userProfiles[$user->userID] = $user;
+ // this method does not return null for non-existing user profiles
+ foreach ($users as $userID => $user) {
+ if ($user === null) {
+ unset($users[$userID]);
}
}
*
* @param string $username
* @return \wcf\data\user\UserProfile
+ * @todo move to UserProfileCache?
*/
public static function getUserProfileByUsername($username) {
$users = self::getUserProfilesByUsername(array($username));
*
* @param array<string> $usernames
* @return array<\wcf\data\user\UserProfile>
+ * @todo move to UserProfileCache?
*/
public static function getUserProfilesByUsername(array $usernames) {
$users = array();
unset($username);
// check cache
+ $userProfiles = UserProfileCache::getInstance()->getCachedUserProfiles();
foreach ($usernames as $index => $username) {
- foreach (self::$userProfiles as $user) {
+ foreach ($userProfiles as $user) {
if (mb_strtolower($user->username) === $username) {
$users[$username] = $user;
unset($usernames[$index]);
--- /dev/null
+<?php
+namespace wcf\data\user;
+use wcf\system\SingletonFactory;
+
+/**
+ * Caches user profile objects during runtime.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.user
+ * @category Community Framework
+ */
+class UserProfileCache extends SingletonFactory {
+ /**
+ * cached user ids whose profiles will be loaded during the next request
+ * @var array<integer>
+ */
+ protected $userIDs = array();
+
+ /**
+ * locally cached user profiles
+ * @var array<\wcf\data\user\UserProfile>
+ */
+ protected $userProfiles = array();
+
+ /**
+ * Caches the given user id.
+ *
+ * @param integer $userID
+ */
+ public function cacheUserID($userID) {
+ $this->userIDs[] = $userID;
+ }
+
+ /**
+ * Caches the given user ids.
+ *
+ * @param array<integer> $userID
+ */
+ public function cacheUserIDs(array $userIDs) {
+ $this->userIDs = array_merge($this->userIDs, $userIDs);
+ }
+
+ /**
+ * Returns all currently cached user profile objects.
+ *
+ * @return array<\wcf\data\user\UserProfile>
+ */
+ public function getCachedUserProfiles() {
+ return $this->userProfiles;
+ }
+
+ /**
+ * 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
+ */
+ public function getUserProfile($userID) {
+ if (array_key_exists($userID, $this->userProfiles)) {
+ return $this->userProfiles[$userID];
+ }
+
+ return $this->getUserProfiles(array($userID))[$userID];
+ }
+
+ /**
+ * Returns the user profiles of the users with the given user ids. For ids
+ * without a user profile, null is returned.
+ *
+ * @param array<integer> $userIDs
+ * @return array<\wcf\data\user\UserProfile>
+ */
+ 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;
+ }
+}
<?php
namespace wcf\data\user\activity\event;
use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
use wcf\system\user\activity\event\UserActivityEventHandler;
* @return \wcf\data\user\UserProfile
*/
public function getUserProfile() {
+ if ($this->userProfile === null) {
+ $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ }
+
return $this->userProfile;
}
<?php
namespace wcf\data\user\activity\event;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
use wcf\system\language\LanguageFactory;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\WCF;
// set user profiles
if (!empty($userIDs)) {
- $userIDs = array_unique($userIDs);
-
- $users = UserProfile::getUserProfiles($userIDs);
- foreach ($this->objects as $event) {
- $event->setUserProfile($users[$event->userID]);
- }
+ UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
}
// parse events
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
+use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\MostActiveMembersCacheBuilder;
use wcf\system\request\LinkHandler;
*/
class MostActiveMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
- * user profile list
- * @var \wcf\data\user\UserProfileList
+ * ids of the most active members
+ * @var array<integer>
*/
- public $userProfileList = null;
+ public $mostActiveMemberIDs = array();
/**
* @see \wcf\system\dashboard\box\AbstractDashboardBoxContent::init()
parent::init($box, $page);
// get ids
- $mostActiveMemberIDs = MostActiveMembersCacheBuilder::getInstance()->getData();
- if (!empty($mostActiveMemberIDs)) {
- // get profile data
- $this->userProfileList = new UserProfileList();
- $this->userProfileList->sqlOrderBy = 'user_table.activityPoints DESC';
- $this->userProfileList->setObjectIDs($mostActiveMemberIDs);
- $this->userProfileList->readObjects();
+ $this->mostActiveMemberIDs = MostActiveMembersCacheBuilder::getInstance()->getData();
+ if (!empty($this->mostActiveMemberIDs)) {
+ UserProfileCache::getInstance()->cacheUserIDs($this->mostActiveMemberIDs);
}
$this->fetched();
* @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
*/
protected function render() {
- if ($this->userProfileList == null) return '';
+ if (empty($this->mostActiveMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
$this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=activityPoints&sortOrder=DESC');
}
+
+ $mostActiveMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostActiveMemberIDs);
+ DatabaseObject::sort($mostActiveMembers, 'activityPoints', 'DESC');
+
WCF::getTPL()->assign(array(
- 'mostActiveMembers' => $this->userProfileList
+ 'mostActiveMembers' => $mostActiveMembers
));
return WCF::getTPL()->fetch('dashboardBoxMostActiveMembers');
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
+use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\MostLikedMembersCacheBuilder;
use wcf\system\request\LinkHandler;
*/
class MostLikedMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
- * user profile list
- * @var \wcf\data\user\UserProfileList
+ * ids of the most liked members
+ * @var array<integer>
*/
- public $userProfileList = null;
+ public $mostLikedMemberIDs = array();
/**
* @see \wcf\system\dashboard\box\IDashboardBox::init()
parent::init($box, $page);
// get ids
- $mostLikedMemberIDs = MostLikedMembersCacheBuilder::getInstance()->getData();
- if (!empty($mostLikedMemberIDs)) {
- // get profile data
- $this->userProfileList = new UserProfileList();
- $this->userProfileList->sqlOrderBy = 'user_table.likesReceived DESC';
- $this->userProfileList->setObjectIDs($mostLikedMemberIDs);
- $this->userProfileList->readObjects();
- }
+ $this->mostLikedMemberIDs = MostLikedMembersCacheBuilder::getInstance()->getData();
$this->fetched();
+
+ if (!empty($this->mostLikedMemberIDs)) {
+ UserProfileCache::getInstance()->cacheUserIDs($this->mostLikedMemberIDs);
+ }
}
/**
* @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
*/
protected function render() {
- if ($this->userProfileList == null) return '';
+ if (empty($this->mostLikedMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
$this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=likesReceived&sortOrder=DESC');
}
+
+ $mostLikedMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostLikedMemberIDs);
+ DatabaseObject::sort($mostLikedMembers, 'likesReceived', 'DESC');
+
WCF::getTPL()->assign(array(
- 'mostLikedMembers' => $this->userProfileList
+ 'mostLikedMembers' => $mostLikedMembers
));
return WCF::getTPL()->fetch('dashboardBoxMostLikedMembers');
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
+use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\NewestMembersCacheBuilder;
use wcf\system\request\LinkHandler;
*/
class NewestMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
- * user profile list
- * @var \wcf\data\user\UserProfileList
+ * ids of the newest members
+ * @var array<integer>
*/
- public $userProfileList = null;
+ public $newestMemberIDs = array();
/**
* @see \wcf\system\dashboard\box\IDashboardBox::init()
parent::init($box, $page);
// get ids
- $newestMemberIDs = NewestMembersCacheBuilder::getInstance()->getData();
- if (!empty($newestMemberIDs)) {
- // get profile data
- $this->userProfileList = new UserProfileList();
- $this->userProfileList->sqlOrderBy = 'user_table.registrationDate DESC';
- $this->userProfileList->setObjectIDs($newestMemberIDs);
- $this->userProfileList->readObjects();
+ $this->newestMemberIDs = NewestMembersCacheBuilder::getInstance()->getData();
+ if (!empty($this->newestMemberIDs)) {
+ UserProfileCache::getInstance()->cacheUserIDs($this->newestMemberIDs);
}
$this->fetched();
* @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
*/
protected function render() {
- if ($this->userProfileList == null) return '';
+ if (empty($this->newestMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
$this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=registrationDate&sortOrder=DESC');
}
+
+ $newestMembers = UserProfileCache::getInstance()->getUserProfiles($this->newestMemberIDs);
+ DatabaseObject::sort($newestMembers, 'registrationDate', 'DESC');
+
WCF::getTPL()->assign(array(
- 'newestMembers' => $this->userProfileList
+ 'newestMembers' => $newestMembers
));
return WCF::getTPL()->fetch('dashboardBoxNewestMembers');
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
use wcf\page\IPage;
use wcf\system\cache\builder\UserOptionCacheBuilder;
use wcf\system\user\UserBirthdayCache;
if (isset($userOptions['birthday'])) {
$birthdayUserOption = $userOptions['birthday'];
- $userProfileList = new UserProfileList();
- $userProfileList->setObjectIDs($userIDs);
- $userProfileList->readObjects();
+ $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+
$i = 0;
- foreach ($userProfileList as $userProfile) {
+ foreach ($userProfiles as $userProfile) {
if ($i == 10) break;
$birthdayUserOption->setUser($userProfile->getDecoratedObject());
-
+
if (!$userProfile->isProtected() && $birthdayUserOption->isVisible() && substr($userProfile->birthday, 5) == $currentDay) {
$this->userProfiles[] = $userProfile;
$i++;
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
use wcf\page\IPage;
use wcf\system\user\UserBirthdayCache;
use wcf\system\WCF;
$userIDs = array_intersect($userIDs, WCF::getUserProfileHandler()->getFollowingUsers());
if (!empty($userIDs)) {
- $userProfileList = new UserProfileList();
- $userProfileList->setObjectIDs($userIDs);
- $userProfileList->readObjects();
+ $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+
$i = 0;
- foreach ($userProfileList as $userProfile) {
+ foreach ($userProfiles as $userProfile) {
if ($i == 10) break;
if (!$userProfile->isProtected() && substr($userProfile->birthday, 5) == $currentDay) {
<?php
namespace wcf\system\message\embedded\object;
use wcf\data\user\UserList;
-use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileCache;
/**
* IMessageEmbeddedObjectHandler implementation for quotes.
* @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::loadObjects()
*/
public function loadObjects(array $objectIDs) {
- return UserProfile::getUserProfiles($objectIDs);
+ return UserProfileCache::getInstance()->getUserProfiles($objectIDs);
}
}
namespace wcf\system\user\activity\event;
use wcf\data\comment\response\CommentResponseList;
use wcf\data\comment\CommentList;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
use wcf\system\user\activity\event\IUserActivityEvent;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
$userIDs[] = $comment->userID;
}
if (!empty($userIDs)) {
- $userList = new UserProfileList();
- $userList->setObjectIDs($userIDs);
- $userList->readObjects();
- $users = $userList->getObjects();
+ $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
}
// set message
<?php
namespace wcf\system\user\activity\event;
use wcf\data\comment\CommentList;
-use wcf\data\user\UserProfileList;
+use wcf\data\user\UserProfileCache;
use wcf\system\user\activity\event\IUserActivityEvent;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
$userIDs[] = $comment->objectID;
}
if (!empty($userIDs)) {
- $userList = new UserProfileList();
- $userList->setObjectIDs($userIDs);
- $userList->readObjects();
- $users = $userList->getObjects();
+ $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
}
// set message