Bläddra i källkod

Merge pull request #23215 from nextcloud/bugfix/noid/only-run-the-query-once

Only run the query to get the account data once
tags/v21.0.0beta1
Roeland Jago Douma 3 år sedan
förälder
incheckning
0c89954488
Inget konto är kopplat till bidragsgivarens mejladress
1 ändrade filer med 7 tillägg och 5 borttagningar
  1. 7
    5
      lib/private/Accounts/AccountManager.php

+ 7
- 5
lib/private/Accounts/AccountManager.php Visa fil

public function getUser(IUser $user) { public function getUser(IUser $user) {
$uid = $user->getUID(); $uid = $user->getUID();
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('data')->from($this->table)
$query->select('data')
->from($this->table)
->where($query->expr()->eq('uid', $query->createParameter('uid'))) ->where($query->expr()->eq('uid', $query->createParameter('uid')))
->setParameter('uid', $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); $userData = $this->buildDefaultUserRecord($user);
$this->insertNewUser($user, $userData); $this->insertNewUser($user, $userData);
return $userData; return $userData;
} }


$userDataArray = json_decode($result[0]['data'], true);
$userDataArray = json_decode($accountData[0]['data'], true);
$jsonError = json_last_error(); $jsonError = json_last_error();
if ($userDataArray === null || $userDataArray === [] || $jsonError !== JSON_ERROR_NONE) { 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"); $this->logger->critical("User data of $uid contained invalid JSON (error $jsonError), hence falling back to a default user record");

Laddar…
Avbryt
Spara