Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-10-06 16:58:34 +0300
committerGitHub <noreply@github.com>2020-10-06 16:58:34 +0300
commiteba468d888553c211475630a1701d96f5d2b2720 (patch)
treecbe6b7319b4b1bd97c9aebdd6fc702dcdba34221
parent867e628f54ab0f108613bf4925ec9d0e2fd8871e (diff)
parent0fed0903e361b41dd60d8ad0c5d7bcd62393775c (diff)
Merge pull request #23221 from nextcloud/backport/23215/stable19
[stable19] Only run the query to get the account data once
-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");