diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-06 10:34:34 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-06 10:34:34 +0200 |
commit | ac59f23daac6386f71a50a620d85e5f2d3e8de19 (patch) | |
tree | 0f1d009c9133d2f1e166b86b77d0398a5f3aed31 /lib/private/Accounts | |
parent | e0372e3a438c6016f80bcde48493c0dbb8a639ea (diff) | |
download | nextcloud-server-ac59f23daac6386f71a50a620d85e5f2d3e8de19.tar.gz nextcloud-server-ac59f23daac6386f71a50a620d85e5f2d3e8de19.zip |
Only run the query to get the account data once
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 7b99fb0a410..1f23e7e33a3 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -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"); |