8000 Merge branch '2.6' into 2.7 · symfony/symfony@7ea7035 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ea7035

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: remove short array syntax fix session restart on PHP 5.3 Avoid missing method when using __invoke
2 parents 55ca36e + f691ab3 commit 7ea7035

File tree

6 files changed

+33
-43
lines changed

6 files changed

+33
-43
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public function testFirewallWithInvalidUserProvider()
8080

8181
$container->loadFromExtension('security', array(
8282
'providers' => array(
83-
'my_foo' => array('foo' => []),
83+
'my_foo' => array('foo' => array()),
8484
),
8585

8686
'firewalls' => array(
8787
'some_firewall' => array(
8888
'pattern' => '/.*',
89-
'http_basic' => [],
89+
'http_basic' => array(),
9090
),
9191
),
9292
));

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
{% set request_handler %}
55
{% if collector.controller.class is defined %}
66
{% set link = collector.controller.file|file_link(collector.controller.line) %}
7-
<span class="sf-toolbar-info-class sf-toolbar-info-with-next-pointer">{{ collector.controller.class|abbr_class }}</span>
8-
<span class="sf-toolbar-info-method" onclick="{% if link %}window.location='{{link|e('js')}}';window.event.stopPropagation();return false;{% endif %}">
9-
{{ collector.controller.method }}
10-
</span>
7+
{% if collector.controller.method %}
8+
<span class="sf-toolbar-info-class sf-toolbar-info-with-next-pointer">{{ collector.controller.class|abbr_class }}</span>
9+
<span class="sf-toolbar-info-method" onclick="{% if link %}window.location='{{link|e('js')}}';window.event.stopPropagation();return false;{% endif %}">
10+
{{ collector.controller.method }}
11+
</span>
12+
{% else %}
13+
<span class="sf-toolbar-info-class" onclick="{% if link %}window.location='{{link|e('js')}}';window.event.stopPropagation();return false;{% endif %}">{{ collector.controller.class|abbr_class }}</span>
14+
{% endif %}
1115
{% else %}
1216
<span class="sf-toolbar-info-class">{{ collector.controller }}</span>
1317
{% endif %}

src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function setSessionData(array $array)
8989
*/
9090
public function start()
9191
{
92-
if ($this->started && !$this->closed) {
92+
if ($this->started) {
9393
return true;
9494
}
9595

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ public function getSaveHandler()
126126
*/
127127
public function start()
128128
{
129-
if ($this->started && !$this->closed) {
129+
if ($this->started) {
130130
return true;
131131
}
132132

133133
if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) {
134134
throw new \RuntimeException('Failed to start the session: already started by PHP.');
135135
}
136136

137-
if (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) {
137+
if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) {
138138
// not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3
139139
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
140140
}
@@ -162,10 +162,6 @@ public function start()
162162
*/
163163
public function getId()
164164
{
165-
if (!$this->started && !$this->closed) {
166-
return ''; // returning empty is consistent with session_id() behaviour
167-
}
168-
169165
return $this->saveHandler->getId();
170166
}
171167

src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($handler = null, MetadataBag $metaBag = null)
3838
*/
3939
public function start()
4040
{
41-
if ($this->started && !$this->closed) {
41+
if ($this->started) {
4242
return true;
4343
}
4444

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 19 additions & 29 deletions
D4CB
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ public function testRegisterBagException()
8585
public function testGetId()
8686
{
8787
$storage = $this->getStorage();
88-
$this->assertEquals('', $storage->getId());
88+
$this->assertSame('', $storage->getId(), 'Empty ID before starting session');
8989

9090
$storage->start();
91-
$this->assertNotEquals('', $storage->getId());
91+
$id = $storage->getId();
92+
$this->assertInternalType('string', $id);
93+
$this->assertNotSame('', $id);
9294

9395
$storage->save();
94-
$this->assertNotEquals('', $storage->getId());
96+
$this->assertSame($id, $storage->getId(), 'ID stays after saving session');
9597
}
9698

9799
public function testRegenerate()
@@ -209,18 +211,20 @@ public function testSetSaveHandler54()
209211
/**
210212
* @expectedException \RuntimeException
211213
*/
212-
public function testStartedOutside53()
214+
public function testStartedOutside()
213215
{
214-
if (PHP_VERSION_ID >= 50400) {
215-
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
216-
}
217-
218216
$storage = $this->getStorage();
219217

220218
$this->assertFalse(isset($_SESSION));
219+
$this->assertFalse($storage->getSaveHandler()->isActive());
220+
$this->assertFalse($storage->isStarted());
221221

222222
session_start();
223223
$this->assertTrue(isset($_SESSION));
224+
if (PHP_VERSION_ID >= 50400) {
225+
// this only works in PHP >= 5.4 where session_status is available
226+
$this->assertTrue($storage->getSaveHandler()->isActive());
227+
}
224228
// PHP session might have started, but the storage driver has not, so false is correct here
225229
$this->assertFalse($storage->isStarted());
226230

@@ -229,29 +233,15 @@ public function testStartedOutside53()
229233
$storage->start();
230234
}
231235

232-
/**
233-
* @expectedException \RuntimeException
234-
*/
235-
public function testCanStartOutside54()
236+
public function testRestart()
236237
{
237-
if (PHP_VERSION_ID < 50400) {
238-
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
239-
}
240-
241238
$storage = $this->getStorage();
242-
243-
$this->assertFalse(isset($_SESSION));
244-
$this->assertFalse($storage->getSaveHandler()->isActive());
245-
$this->assertFalse($storage->isStarted());
246-
247-
session_start();
248-
$this->assertTrue(isset($_SESSION));
249-
$this->assertTrue($storage->getSaveHandler()->isActive());
250-
// PHP session might have started, but the storage driver has not, so false is correct here
251-
$this->assertFalse($storage->isStarted());
252-
253-
$key = $storage->getMetadataBag()->getStorageKey();
254-
$this->assertFalse(isset($_SESSION[$key]));
255239
$storage->start();
240+
$id = $storage->getId();
241+
$storage->getBag('attributes')->set('lucky', 7);
242+
$storage->save();
243+
$storage->start();
244+
$this->assertSame($id, $storage->getId(), 'Same session ID after restarting');
245+
$this->assertSame(7, $storage->getBag('attributes')->get('lucky'), 'Data still available');
256246
}
257247
}

0 commit comments

Comments
 (0)
0