]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only run the query to get the account data once 23220/head
authorJoas Schilling <coding@schilljs.com>
Tue, 6 Oct 2020 08:34:34 +0000 (10:34 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 6 Oct 2020 10:48:24 +0000 (10:48 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Accounts/AccountManager.php

index 7b99fb0a4103ef592dac7d5799f64487acffa009..1f23e7e33a360705ecb33689b8f86b86d9cc6e8d 100644 (file)
@@ -134,19 +134,21 @@ class AccountManager implements IAccountManager {
        public function getUser(IUser $user) {
                $uid = $user->getUID();
                $query = $this->connection->getQueryBuilder();
-               $query->select('data')->from($this->table)
+               $query->select('data')
+                       ->from($this->table)
                        ->where($query->expr()->eq('uid', $query->createParameter('uid')))
                        ->setParameter('uid', $uid);
-               $query->execute();
-               $result = $query->execute()->fetchAll();
+               $result = $query->execute();
+               $accountData = $result->fetchAll();
+               $result->closeCursor();
 
-               if (empty($result)) {
+               if (empty($accountData)) {
                        $userData = $this->buildDefaultUserRecord($user);
                        $this->insertNewUser($user, $userData);
                        return $userData;
                }
 
-               $userDataArray = json_decode($result[0]['data'], true);
+               $userDataArray = json_decode($accountData[0]['data'], true);
                $jsonError = json_last_error();
                if ($userDataArray === null || $userDataArray === [] || $jsonError !== JSON_ERROR_NONE) {
                        $this->logger->critical("User data of $uid contained invalid JSON (error $jsonError), hence falling back to a default user record");