Skip to content

Commit 69e73cb

Browse files
Merge pull request #31297 from nextcloud/backport/31217/stable23
[stable23] Also cache non-existing to reuse it
2 parents 8415cca + 3df6208 commit 69e73cb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/private/Authentication/Token/PublicKeyTokenProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,17 @@ public function getToken(string $tokenId): IToken {
9797
$tokenHash = $this->hashToken($tokenId);
9898

9999
if (isset($this->cache[$tokenHash])) {
100+
if ($this->cache[$tokenHash] instanceof DoesNotExistException) {
101+
$ex = $this->cache[$tokenHash];
102+
throw new InvalidTokenException("Token does not exist: " . $ex->getMessage(), 0, $ex);
103+
}
100104
$token = $this->cache[$tokenHash];
101105
} else {
102106
try {
103107
$token = $this->mapper->getToken($this->hashToken($tokenId));
104108
$this->cache[$token->getToken()] = $token;
105109
} catch (DoesNotExistException $ex) {
110+
$this->cache[$tokenHash] = $ex;
106111
throw new InvalidTokenException("Token does not exist: " . $ex->getMessage(), 0, $ex);
107112
}
108113
}

0 commit comments

Comments
 (0)