Fix requesting multiple times the UserStorage tables if no cache exists
authorjoshuaruesweg <ruesweg@woltlab.com>
Fri, 16 Apr 2021 10:38:56 +0000 (12:38 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Sun, 18 Apr 2021 10:47:00 +0000 (12:47 +0200)
wcfsetup/install/files/lib/system/user/storage/UserStorageHandler.class.php

index 9ca9ffe257887b5c4a0f0643967d9606732fd370..5b236891003e03621da60799137693a15e16ceed 100644 (file)
@@ -55,7 +55,10 @@ class UserStorageHandler extends SingletonFactory {
                
                $tmp = [];
                foreach ($userIDs as $userID) {
-                       if (!isset($this->cache[$userID])) $tmp[] = $userID;
+                       if (!isset($this->cache[$userID])) {
+                               $tmp[] = $userID;
+                               $this->cache[$userID] = [];
+                       }
                }
                
                // ignore users whose storage data is already loaded
@@ -70,10 +73,6 @@ class UserStorageHandler extends SingletonFactory {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
                while ($row = $statement->fetchArray()) {
-                       if (!isset($this->cache[$row['userID']])) {
-                               $this->cache[$row['userID']] = [];
-                       }
-                       
                        if (isset($this->log[$row['userID']])) {
                                if (array_key_exists($row['field'], $this->log[$row['userID']])) {
                                        $logged = $this->log[$row['userID']][$row['field']];