aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-10-06 13:52:12 +0200
committerGitHub <noreply@github.com>2020-10-06 13:52:12 +0200
commit806fc5970948161e6b5ffc49caca728c2af78160 (patch)
tree2e28f99c22f1b2a32ca157bbbc22616634124995
parentbefd1aef420189567179742cce900d2319f1988b (diff)
parent90fc06eb7cebbd5b2a329079e52c037e2f209ca2 (diff)
downloadnextcloud-server-806fc5970948161e6b5ffc49caca728c2af78160.tar.gz
nextcloud-server-806fc5970948161e6b5ffc49caca728c2af78160.zip
Merge pull request #23222 from nextcloud/backport/23215/stable18
[stable18] 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 5f2ea465ed7..ec55522efd5 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");