Skip to content

Commit 3bfe9cd

Browse files
Merge branch '5.3' into 5.4
* 5.3: [HttpClient] mark test transient [Mime] Fix test [Translation] Fix TranslationPullCommand with ICU translations Allow package-versions-deprecated plugin Update security.lb.xlf [Notifier] Use correct factory for the msteams transport Fix SessionListener without session in request Remove direct dependency on composer/package-versions-deprecated Remove the unused dependency on composer/package-versions-deprecated [Security/Http] Fix cookie clearing on logout [HttpClient] fix checking for recent curl consts
2 parents 77b2fe7 + f3463aa commit 3bfe9cd

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

EventListener/AbstractSessionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function onKernelRequest(RequestEvent $event)
9393

9494
public function onKernelResponse(ResponseEvent $event)
9595
{
96-
if (!$event->isMainRequest()) {
96+
if (!$event->isMainRequest() || (!$this->container->has('initialized_session') && !$event->getRequest()->hasSession())) {
9797
return;
9898
}
9999

Tests/EventListener/SessionListenerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,24 @@ public function testUninitializedSession()
283283
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
284284
}
285285

286+
public function testUninitializedSessionWithoutInitializedSession()
287+
{
288+
$kernel = $this->createMock(HttpKernelInterface::class);
289+
$response = new Response();
290+
$response->setSharedMaxAge(60);
291+
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true');
292+
293+
$container = new ServiceLocator([]);
294+
295+
$listener = new SessionListener($container);
296+
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
297+
$this->assertFalse($response->headers->has('Expires'));
298+
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
299+
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
300+
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
301+
$this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
302+
}
303+
286304
public function testSurrogateMainRequestIsPublic()
287305
{
288306
$session = $this->createMock(Session::class);

0 commit comments

Comments
 (0)