From 1f679c05fae3dc0e41d68f01c79c91c2d5901d70 Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Thu, 20 Jul 2023 12:41:40 +0200 Subject: [PATCH 1/4] IBX-6207: Requests containing front controller script causes session-not-found exception --- .../EventListener/SessionInitByPostListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php index 3c9beb91e0..c76c70923c 100644 --- a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php +++ b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php @@ -27,7 +27,7 @@ public static function getSubscribedEvents() public function onSiteAccessMatch(PostSiteAccessMatchEvent $event) { $request = $event->getRequest(); - $session = $request->getSession(); + $request->hasSession() ? $session = $request->getSession() : $session = false; if (!$session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { return; From 79ff02de0c88a2208fb9844d891ec1f31b84d6cb Mon Sep 17 00:00:00 2001 From: Vidar Date: Wed, 26 Jul 2023 09:29:20 +0200 Subject: [PATCH 2/4] Update eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Niedzielski --- .../EventListener/SessionInitByPostListener.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php index c76c70923c..ba9d13101a 100644 --- a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php +++ b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php @@ -27,7 +27,10 @@ public static function getSubscribedEvents() public function onSiteAccessMatch(PostSiteAccessMatchEvent $event) { $request = $event->getRequest(); - $request->hasSession() ? $session = $request->getSession() : $session = false; + $session = null; + if ($request->hasSession()) { + $session = $request->getSession(); + } if (!$session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { return; From 0c9343fa45c07153aaaa29e4fdcc8d7c6262ad05 Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Thu, 3 Aug 2023 11:13:34 +0200 Subject: [PATCH 3/4] fixup! IBX-6207: Requests containing front controller script causes session-not-found exception --- .../Tests/EventListener/SessionInitByPostListenerTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php index c5ce15ea8d..5bb203732c 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php +++ b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php @@ -117,4 +117,12 @@ public function testOnSiteAccessMatchNewSessionName() $this->listener->onSiteAccessMatch($event); } + + public function testOnSiteAccessMatchNoSession() + { + $request = new Request(); + + $event = new PostSiteAccessMatchEvent(new SiteAccess('test'), $request, HttpKernelInterface::MAIN_REQUEST); + $this->listener->onSiteAccessMatch($event); + } } From 5d5a58015a8d2b9339d3c8254cbac1c43f28a3f7 Mon Sep 17 00:00:00 2001 From: Vidar Date: Wed, 6 Sep 2023 14:32:08 +0200 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Andrew Longosz --- .../EventListener/SessionInitByPostListener.php | 2 +- .../Tests/EventListener/SessionInitByPostListenerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php index ba9d13101a..5048b939de 100644 --- a/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php +++ b/eZ/Bundle/EzPublishCoreBundle/EventListener/SessionInitByPostListener.php @@ -32,7 +32,7 @@ public function onSiteAccessMatch(PostSiteAccessMatchEvent $event) $session = $request->getSession(); } - if (!$session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { + if (null === $session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) { return; } diff --git a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php index 5bb203732c..76e3cbc50c 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php +++ b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/SessionInitByPostListenerTest.php @@ -118,7 +118,7 @@ public function testOnSiteAccessMatchNewSessionName() $this->listener->onSiteAccessMatch($event); } - public function testOnSiteAccessMatchNoSession() + public function testOnSiteAccessMatchNoSession(): void { $request = new Request();