Skip to content

Commit

Permalink
SF6: catch SessionNotFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Aug 3, 2023
1 parent 3243682 commit 84e6869
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/EventListener/FlashMessageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
Expand Down Expand Up @@ -82,7 +83,12 @@ public function onKernelResponse(FlashMessageResponseEvent $event)
return;
}

$session = $this->session ?: $event->getRequest()->getSession();
try {
$session = $this->session ?: $event->getRequest()->getSession();
} catch (SessionNotFoundException $e) {
return;
}

if (null === $session) {
return;
}
Expand Down

0 comments on commit 84e6869

Please sign in to comment.