Skip to content

Commit 4e282ac

Browse files
authored
Merge pull request #7375 from nextcloud/backport/7372/stable30
[stable30] debug(SessionMiddleware): Log if we have an invalid session
2 parents d48e44a + 68f17ed commit 4e282ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Middleware/SessionMiddleware.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCP\IUserSession;
3131
use OCP\Share\Exceptions\ShareNotFound;
3232
use OCP\Share\IManager as ShareManager;
33+
use Psr\Log\LoggerInterface;
3334
use ReflectionException;
3435

3536
class SessionMiddleware extends Middleware {
@@ -43,6 +44,7 @@ public function __construct(
4344
private IRootFolder $rootFolder,
4445
private ShareManager $shareManager,
4546
private IL10N $l10n,
47+
private LoggerInterface $logger,
4648
) {
4749
}
4850

@@ -99,11 +101,15 @@ private function assertDocumentSession(ISessionAwareController $controller): voi
99101

100102
$session = $this->sessionService->getValidSession($documentId, $sessionId, $token);
101103
if (!$session) {
104+
// We spotted occurrences of this in combination with out-of-sync situations, so let's log it for now.
105+
$this->logger->error('Could not find document session for document id' . $documentId . ' and session id ' . $sessionId);
102106
throw new InvalidSessionException();
103107
}
104108

105109
$document = $this->documentService->getDocument($documentId);
106110
if (!$document) {
111+
// We spotted occurrences of this in combination with out-of-sync situations, so let's log it for now.
112+
$this->logger->error('Could not find document for documentId ' . $documentId);
107113
throw new InvalidSessionException();
108114
}
109115

0 commit comments

Comments
 (0)