Skip to content

Commit

Permalink
Merge branch '4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Nov 3, 2023
2 parents 49d459b + c649c39 commit 2d275ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bundle/Core/EventListener/SessionInitByPostListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public static function getSubscribedEvents()
public function onSiteAccessMatch(PostSiteAccessMatchEvent $event)
{
$request = $event->getRequest();
$session = $request->getSession();
$session = null;
if ($request->hasSession()) {
$session = $request->getSession();
}

if (!$session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
if (null === $session || $event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ public function testOnSiteAccessMatchNewSessionName()

$this->listener->onSiteAccessMatch($event);
}

public function testOnSiteAccessMatchNoSession(): void
{
$request = new Request();

$event = new PostSiteAccessMatchEvent(new SiteAccess('test'), $request, HttpKernelInterface::MAIN_REQUEST);
$this->listener->onSiteAccessMatch($event);
}
}

class_alias(SessionInitByPostListenerTest::class, 'eZ\Bundle\EzPublishCoreBundle\Tests\EventListener\SessionInitByPostListenerTest');

0 comments on commit 2d275ad

Please sign in to comment.