From c48646d5bfc94ef7190dd5f1979d93865dbb51cb Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Mon, 11 Jan 2021 13:54:23 +0100 Subject: [PATCH] Fix multiple queries for user online list stats --- .../user/online/UsersOnlineList.class.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php index 3852d932a3..9aed41014b 100644 --- a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php @@ -99,21 +99,29 @@ class UsersOnlineList extends SessionList { ".$conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditionBuilder->getParameters()); + + $users = $userIDs = []; while ($row = $statement->fetchArray()) { - $user = new UserOnline(new User(null, $row)); - $this->stats['total']++; + + $user = new UserOnline(new User(null, $row)); if ($user->userID) { $this->stats['members']++; - - if ($user->canViewOnlineStatus && !self::isVisibleUser($user)) { - $this->stats['invisible']++; - } + $users[] = $user; + $userIDs[] = $user->userID; } else { $this->stats['guests']++; } } + + UserStorageHandler::getInstance()->loadStorage($userIDs); + + foreach ($users as $user) { + if ($user->canViewOnlineStatus && !self::isVisibleUser($user)) { + $this->stats['invisible']++; + } + } } /** -- 2.20.1