Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a930a67

Browse filesBrowse files
committed
When session is active, do not change options with PHP 7.2
1 parent cfb86c0 commit a930a67
Copy full SHA for a930a67

File tree

2 files changed

+19
-22
lines changed
Filter options

2 files changed

+19
-22
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
+14-16Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,23 @@ public function __construct(array $options = array(), $handler = null, MetadataB
105105
$this->setMetadataBag($metaBag);
106106

107107
if (PHP_VERSION_ID >= 70200 && \PHP_SESSION_ACTIVE === session_status()) {
108-
if (!empty($options) || null !== $handler) {
109-
throw new \LogicException('Cannot change options or handler of an active session');
110-
}
111-
} else {
112-
$options += array(
113-
// disable by default because it's managed by HeaderBag (if used)
114-
'cache_limiter' => '',
115-
'use_cookies' => 1,
116-
);
108+
return;
109+
}
117110

118-
if (\PHP_VERSION_ID >= 50400) {
119-
session_register_shutdown();
120-
} else {
121-
register_shutdown_function('session_write_close');
122-
}
111+
$options += array(
112+
// disable by default because it's managed by HeaderBag (if used)
113+
'cache_limiter' => '',
114+
'use_cookies' => 1,
115+
);
123116

124-
$this->setOptions($options);
125-
$this->setSaveHandler($handler);
117+
if (\PHP_VERSION_ID >= 50400) {
118+
session_register_shutdown();
119+
} else {
120+
register_shutdown_function('session_write_close');
126121
}
122+
123+
$this->setOptions($options);
124+
$this->setSaveHandler($handler);
127125
}
128126

129127
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,16 @@ public function testCanCreateNativeSessionStorageWhenSessionAlreadyStarted()
283283
}
284284

285285
/**
286-
* @expectedException \LogicException
286+
* @requires PHP 7.2
287287
*/
288-
public function testCannotSetSessionOptionsOnceSessionStarted()
288+
public function testSetSessionOptionsOnceSessionStartedIsIgnored()
289289
{
290-
if (PHP_VERSION_ID < 70200) {
291-
$this->markTestSkipped('Limitation from PHP 7.2 only');
292-
}
293-
294290
session_start();
295291
$this->getStorage(array(
296292
'name' => 'something-else',
297293
));
294+
295+
// Assert no exception has been thrown by `getStorage()`
296+
$this->assertTrue(true);
298297
}
299298
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.