From 3df6208537fefd63ff81fd29ca756bd5378c7f8a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Feb 2022 16:51:22 +0100 Subject: [PATCH] Also cache non-existing to reuse it Signed-off-by: Joas Schilling --- lib/private/Authentication/Token/PublicKeyTokenProvider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index b9cfce6c86930..b7c8a8e9c2463 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -97,12 +97,17 @@ public function getToken(string $tokenId): IToken { $tokenHash = $this->hashToken($tokenId); if (isset($this->cache[$tokenHash])) { + if ($this->cache[$tokenHash] instanceof DoesNotExistException) { + $ex = $this->cache[$tokenHash]; + throw new InvalidTokenException("Token does not exist: " . $ex->getMessage(), 0, $ex); + } $token = $this->cache[$tokenHash]; } else { try { $token = $this->mapper->getToken($this->hashToken($tokenId)); $this->cache[$token->getToken()] = $token; } catch (DoesNotExistException $ex) { + $this->cache[$tokenHash] = $ex; throw new InvalidTokenException("Token does not exist: " . $ex->getMessage(), 0, $ex); } }