Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commiteaeb820

Browse files
Merge branch '3.3' into 3.4
* 3.3: [HttpFoundation] Fix forward-compat of NativeSessionStorage with PHP 7.2
2 parentse7cfaa9 +ed52036 commiteaeb820

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ class NativeSessionStorage implements SessionStorageInterface
100100
*/
101101
publicfunction__construct(array$options =array(),$handler =null,MetadataBag$metaBag =null)
102102
{
103+
$this->setMetadataBag($metaBag);
104+
105+
if (\PHP_SESSION_ACTIVE ===session_status()) {
106+
return;
107+
}
108+
103109
$options +=array(
104110
'cache_limiter' =>'private_no_expire',
105111
'cache_expire' =>0,
@@ -109,7 +115,6 @@ public function __construct(array $options = array(), $handler = null, MetadataB
109115

110116
session_register_shutdown();
111117

112-
$this->setMetadataBag($metaBag);
113118
$this->setOptions($options);
114119
$this->setSaveHandler($handler);
115120
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,24 @@ public function testRestart()
242242
$this->assertSame($id,$storage->getId(),'Same session ID after restarting');
243243
$this->assertSame(7,$storage->getBag('attributes')->get('lucky'),'Data still available');
244244
}
245+
246+
publicfunctiontestCanCreateNativeSessionStorageWhenSessionAlreadyStarted()
247+
{
248+
session_start();
249+
$this->getStorage();
250+
251+
// Assert no exception has been thrown by `getStorage()`
252+
$this->addToAssertionCount(1);
253+
}
254+
255+
publicfunctiontestSetSessionOptionsOnceSessionStartedIsIgnored()
256+
{
257+
session_start();
258+
$this->getStorage(array(
259+
'name' =>'something-else',
260+
));
261+
262+
// Assert no exception has been thrown by `getStorage()`
263+
$this->addToAssertionCount(1);
264+
}
245265
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp