Skip to content

Commit 10708bf

Browse files
authored
Merge pull request #595 from ro0NL/ro0NL-patch-1
SF6: catch SessionNotFoundException
2 parents 3243682 + 84e6869 commit 10708bf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/EventListener/FlashMessageListener.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\HttpFoundation\Cookie;
16+
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
1617
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
1718
use Symfony\Component\HttpFoundation\Session\Session;
1819
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@@ -82,7 +83,12 @@ public function onKernelResponse(FlashMessageResponseEvent $event)
8283
return;
8384
}
8485

85-
$session = $this->session ?: $event->getRequest()->getSession();
86+
try {
87+
$session = $this->session ?: $event->getRequest()->getSession();
88+
} catch (SessionNotFoundException $e) {
89+
return;
90+
}
91+
8692
if (null === $session) {
8793
return;
8894
}

0 commit comments

Comments
 (0)