aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Accounts/AccountManager.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2023-06-01 20:19:24 +0200
committerSimon L <szaimen@e.mail.de>2023-06-12 09:44:48 +0200
commitb8c61b3515ef406c4feafc851f12262e417ba157 (patch)
tree5c45a7174c899ef5dc1618158f57948cf7a551ff /lib/private/Accounts/AccountManager.php
parentc93be182dc0172eed377ba70ce54cd7c83689764 (diff)
downloadnextcloud-server-b8c61b3515ef406c4feafc851f12262e417ba157.tar.gz
nextcloud-server-b8c61b3515ef406c4feafc851f12262e417ba157.zip
fix(caching): Avoid checking existence before fetching
The cache might expire between checking for key existence and fetching the value. In this rare case the code continues with a null value when it doesn't expect one. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Accounts/AccountManager.php')
-rw-r--r--lib/private/Accounts/AccountManager.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php
index 60065272a58..e3068a7ff25 100644
--- a/lib/private/Accounts/AccountManager.php
+++ b/lib/private/Accounts/AccountManager.php
@@ -795,8 +795,9 @@ class AccountManager implements IAccountManager {
}
public function getAccount(IUser $user): IAccount {
- if ($this->internalCache->hasKey($user->getUID())) {
- return $this->internalCache->get($user->getUID());
+ $cached = $this->internalCache->get($user->getUID());
+ if ($cached !== null) {
+ return $cached;
}
$account = $this->parseAccountData($user, $this->getUser($user));
$this->internalCache->set($user->getUID(), $account);