Fix multiple queries for user online list stats
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 11 Jan 2021 12:54:23 +0000 (13:54 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Mon, 11 Jan 2021 12:54:40 +0000 (13:54 +0100)
wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php

index 3852d932a3ef64fdda2813a70da1c0ee69a2b19a..9aed41014b01876397edfdf90ebf8213745d9d92 100644 (file)
@@ -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']++;
+                       }
+               }
        }
        
        /**