Skip to content

Commit 0fa9cb1

Browse files
Merge branch '3.1'
* 3.1: [travis] Don't use parallel on HHVM [HttpKernel] Fix RequestDataCollector starting the session [appveyor] Ignore STATUS_HEAP_CORRUPTION errors on Windows [FrameworkBundle] Skip redis cache pools test on failed connection Fixed forwarded request data in templates [Security] Fix DebugAccessDecisionManager when object is not a scalar Skip some tests on HHVM due to a PHPunit bug Use the Trusty Travis infrastructure for HHVM builds LdapUserProvider: add missing argument type doc Fixed issue with missing argument in the abstract service definition for the ldap user provider Add 3.1 to PR template branch row, remove 2.3 Improve memory efficiency [Console] Fix BC break introduced by #18101 document method name changes in Voter class add missing hint for vote() argument type [#18838] add a test to avoid regressions bumped Symfony version to 3.1.1 updated VERSION for 3.1.0 updated CHANGELOG for 3.1.0 Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
2 parents 5d32a40 + de4ca93 commit 0fa9cb1

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

DataCollector/RequestDataCollector.php

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

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

292292
public function onKernelResponse(FilterResponseEvent $event)
293293
{
294-
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession()) {
294+
if (!$event->isMasterRequest() || !$event->getRequest()->hasSession() || !$event->getRequest()->getSession()->isStarted()) {
295295
return;
296296
}
297297

Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testFlush()
113113
$line = __LINE__ - 1;
114114

115115
ob_start();
116-
$collector = null;
116+
$collector->__destruct();
117117
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
118118
}
119119
}

Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
1313

14+
use Symfony\Component\HttpFoundation\Session\Session;
15+
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1416
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
17+
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1518
use Symfony\Component\HttpKernel\HttpKernel;
1619
use Symfony\Component\HttpKernel\HttpKernelInterface;
1720
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
@@ -52,6 +55,20 @@ public function testCollect()
5255
$this->assertSame('application/json', $c->getContentType());
5356
}
5457

58+
public function testKernelResponseDoesNotStartSession()
59+
{
60+
$kernel = $this->getMock(HttpKernelInterface::class);
61+
$request = new Request();
62+
$session = new Session(new MockArraySessionStorage());
63+
$request->setSession($session);
64+
$response = new Response();
65+
66+
$c = new RequestDataCollector();
67+
$c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
68+
69+
$this->assertFalse($session->isStarted());
70+
}
71+
5572
/**
5673
* Test various types of controller callables.
5774
*/

0 commit comments

Comments
 (0)