From: Alexander Ebert Date: Mon, 25 Apr 2016 13:57:09 +0000 (+0200) Subject: Load user storage in bulk to minimize performance impact X-Git-Tag: 3.0.0_Beta_1~1818 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3b945385dbf1b3c6e42c18c18752f1fb089f3091;p=GitHub%2FWoltLab%2FWCF.git Load user storage in bulk to minimize performance impact --- diff --git a/wcfsetup/install/files/lib/page/MembersListPage.class.php b/wcfsetup/install/files/lib/page/MembersListPage.class.php index c283e4c307..99fbd24681 100644 --- a/wcfsetup/install/files/lib/page/MembersListPage.class.php +++ b/wcfsetup/install/files/lib/page/MembersListPage.class.php @@ -1,9 +1,11 @@ * @package com.woltlab.wcf * @subpackage page @@ -25,42 +27,42 @@ class MembersListPage extends SortablePage { public static $availableLetters = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ'; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @inheritDoc */ - public $neededPermissions = array('user.profile.canViewMembersList'); + public $neededPermissions = ['user.profile.canViewMembersList']; /** - * @see \wcf\page\AbstractPage::$neededModules + * @inheritDoc */ - public $neededModules = array('MODULE_MEMBERS_LIST'); + public $neededModules = ['MODULE_MEMBERS_LIST']; /** - * @see \wcf\page\AbstractPage::$enableTracking + * @inheritDoc */ public $enableTracking = true; /** - * @see \wcf\page\MultipleLinkPage::$itemsPerPage + * @inheritDoc */ public $itemsPerPage = MEMBERS_LIST_USERS_PER_PAGE; /** - * @see \wcf\page\SortablePage::$defaultSortField + * @inheritDoc */ public $defaultSortField = MEMBERS_LIST_DEFAULT_SORT_FIELD; /** - * @see \wcf\page\SortablePage::$defaultSortOrder + * @inheritDoc */ public $defaultSortOrder = MEMBERS_LIST_DEFAULT_SORT_ORDER; /** - * @see \wcf\page\SortablePage::$validSortFields + * @inheritDoc */ - public $validSortFields = array('username', 'registrationDate', 'activityPoints', 'likesReceived', 'lastActivityTime'); + public $validSortFields = ['username', 'registrationDate', 'activityPoints', 'likesReceived', 'lastActivityTime']; /** - * @see \wcf\page\MultipleLinkPage::$objectListClassName + * @inheritDoc */ public $objectListClassName = 'wcf\data\user\UserProfileList'; @@ -83,7 +85,7 @@ class MembersListPage extends SortablePage { public $search = null; /** - * @see \wcf\page\IPage::readParameters() + * @inheritDoc */ public function readParameters() { parent::readParameters(); @@ -103,20 +105,20 @@ class MembersListPage extends SortablePage { if (!empty($_POST)) { $parameters = http_build_query($_POST, '', '&'); - HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MembersList', array(), $parameters)); + HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MembersList', [], $parameters)); exit; } } /** - * @see \wcf\page\MultipleLinkPage::initObjectList() + * @inheritDoc */ protected function initObjectList() { parent::initObjectList(); if ($this->search !== null) { $searchData = unserialize($this->search->searchData); - $this->objectList->getConditionBuilder()->add("user_table.userID IN (?)", array($searchData['matches'])); + $this->objectList->getConditionBuilder()->add("user_table.userID IN (?)", [$searchData['matches']]); unset($searchData); } @@ -132,23 +134,41 @@ class MembersListPage extends SortablePage { } } else { - $this->objectList->getConditionBuilder()->add("username LIKE ?", array($this->letter.'%')); + $this->objectList->getConditionBuilder()->add("username LIKE ?", [$this->letter.'%']); } } } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc + */ + protected function readObjects() { + parent::readObjects(); + + $userIDs = []; + /** @var User $user */ + foreach ($this->objectList as $user) { + $userIDs[] = $user->userID; + } + + if (!empty($userIDs)) { + // preload user storage to avoid reading storage for each user separately at runtime + UserStorageHandler::getInstance()->loadStorage($userIDs); + } + } + + /** + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'letters' => str_split(self::$availableLetters), 'letter' => $this->letter, 'searchID' => $this->searchID, 'allowSpidersToIndexThisPage' => true - )); + ]); if (count($this->objectList) === 0) { @header('HTTP/1.0 404 Not Found');