summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-10-06 10:34:34 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-10-06 10:50:58 +0000
commit0fed0903e361b41dd60d8ad0c5d7bcd62393775c (patch)
tree29637aa01e736056a873246a33aadfb17f67be9c /lib
parentc75378ac867498c9f1128df6414359c356074a37 (diff)
downloadnextcloud-server-0fed0903e361b41dd60d8ad0c5d7bcd62393775c.tar.gz
nextcloud-server-0fed0903e361b41dd60d8ad0c5d7bcd62393775c.zip
Only run the query to get the account data once
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Accounts/AccountManager.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 8b0cb972c59..e503ff55021 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 || $jsonError !== JSON_ERROR_NONE) {
$this->logger->critical("User data of $uid contained invalid JSON (error $jsonError), hence falling back to a default user record");