Skip to content

Commit 2e3df94

Browse files
committed
bug symfony#24774 [HttpKernel] Let the storage manage the session starts (sroze)
This PR was squashed before being merged into the 3.4 branch (closes symfony#24774). Discussion ---------- [HttpKernel] Let the storage manage the session starts | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#24730 | License | MIT | Doc PR | ø HttpKernel's request collector should not really care if the session has started or not, be let the storage decide. Without the session, it is not possible to track the redirected pages. I don't think the consideration of "we should not start the session if not needed by the user's code" applies here as if this is running, that is very likely that the user is running the dev environment anyway. Commits ------- 95d0b72 [HttpKernel] Let the storage manage the session starts
2 parents 782dc94 + 95d0b72 commit 2e3df94

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function collect(Request $request, Response $response, \Exception $except
131131
unset($this->controllers[$request]);
132132
}
133133

134-
if (null !== $session && $session->isStarted()) {
134+
if (null !== $session) {
135135
if ($request->attributes->has('_redirected')) {
136136
$this->data['redirect'] = $session->remove('sf_redirect');
137137
}
@@ -315,7 +315,7 @@ public function onKernelController(FilterControllerEvent $event)
315315

316316
public function onKernelResponse(FilterResponseEvent $event)
317317
{
318-
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession() || !$event->getRequest()->getSession()->isStarted()) {
318+
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession()) {
319319
return;
320320
}
321321

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\HttpFoundation\Session\Session;
1818
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1919
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
20-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
2120
use Symfony\Component\HttpKernel\HttpKernel;
2221
use Symfony\Component\HttpKernel\HttpKernelInterface;
2322
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
@@ -71,20 +70,6 @@ public function testCollectWithoutRouteParams()
7170
$this->assertEquals(array(), $c->getRouteParams());
7271
}
7372

74-
public function testKernelResponseDoesNotStartSession()
75-
{
76-
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
77-
$request = new Request();
78-
$session = new Session(new MockArraySessionStorage());
79-
$request->setSession($session);
80-
$response = new Response();
81-
82-
$c = new RequestDataCollector();
83-
$c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
84-
85-
$this->assertFalse($session->isStarted());
86-
}
87-
8873
/**
8974
* @dataProvider provideControllerCallables
9075
*/

0 commit comments

Comments
 (0)