From eec6d4c6168837e3a8cbcbb39c8a8b89e8c966ec Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:59:17 +0100 Subject: [PATCH] refactor(session): exception handling for session decryption Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/private/Session/CryptoSessionData.php | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/private/Session/CryptoSessionData.php b/lib/private/Session/CryptoSessionData.php index 67199aa233788..4aa733872beef 100644 --- a/lib/private/Session/CryptoSessionData.php +++ b/lib/private/Session/CryptoSessionData.php @@ -58,19 +58,19 @@ protected function initializeSession() { 512, JSON_THROW_ON_ERROR, ); - } catch (\RuntimeException $e) { - // Even though this might be critical in general, we are automatically trying again and will likely succeed. - // We only log to info to not spam the logs with a well-known problem the admin cannot do anything about. - // See https://github.com/nextcloud/server/issues/42157 - logger('core')->info('Could not decrypt or decode encrypted session data', [ - 'exception' => $e, - ]); - $this->sessionValues = []; - $this->regenerateId(true, false); } catch (\Exception $e) { - logger('core')->critical('Could not decrypt or decode encrypted session data', [ - 'exception' => $e, - ]); + if ($e instanceof \RuntimeException) { + // Even though this might be critical in general, we are automatically trying again and will likely succeed. + // We only log to info to not spam the logs with a well-known problem the admin cannot do anything about. + // See https://github.com/nextcloud/server/issues/42157 + logger('core')->info('Could not decrypt or decode encrypted session data', [ + 'exception' => $e, + ]); + } else { + logger('core')->critical('Could not decrypt or decode encrypted session data', [ + 'exception' => $e, + ]); + } $this->sessionValues = []; $this->regenerateId(true, false); }