From 3316e3c40a3d95317111dd8d87e2c0e1b31f6623 Mon Sep 17 00:00:00 2001 From: Marc Sallaberremborde Date: Thu, 7 Oct 2021 15:01:41 +0200 Subject: [PATCH] IBX-1218: Fixed a Symfony\Component\HttpFoundation::getSession() call without checking its existence with hasSession() --- .../EventListener/SessionInitByPostListener.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php index c4d3cd572b..d23c3ffc49 100644 --- a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php +++ b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php @@ -27,14 +27,16 @@ public static function getSubscribedEvents() public function onSiteAccessMatch(PostSiteAccessMatchEvent $event) { $request = $event->getRequest(); - $session = $request->getSession(); + if ($event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { + return; + } - if (!$session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { + if (!$request->hasSession()) { return; } + $session = $request->getSession(); $sessionName = $session->getName(); - $request = $event->getRequest(); if ( !$session->isStarted()