Skip to content

Commit

Permalink
Merge pull request #28481 from nextcloud/fix/hash-key
Browse files Browse the repository at this point in the history
Hash cache key
  • Loading branch information
juliusknorr authored Aug 18, 2021
2 parents 7ab39ef + 60ecc43 commit 95987d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function get($uid) {
return $this->cachedUsers[$uid];
}

$cachedBackend = $this->cache->get($uid);
$cachedBackend = $this->cache->get(sha1($uid));
if ($cachedBackend !== null && isset($this->backends[$cachedBackend])) {
// Cache has the info of the user backend already, so ask that one directly
$backend = $this->backends[$cachedBackend];
Expand All @@ -174,7 +174,8 @@ public function get($uid) {
}

if ($backend->userExists($uid)) {
$this->cache->set($uid, $i, 300);
// Hash $uid to ensure that only valid characters are used for the cache key
$this->cache->set(sha1($uid), $i, 300);
return $this->getUserObject($uid, $backend);
}
}
Expand Down

0 comments on commit 95987d9

Please sign in to comment.