Merge branch '2.8' into 3.3
* 2.8: [HttpFoundation] Fix forward-compat of NativeSessionStorage with PHP 7.2
This commit is contained in:
commit
ed52036412
@ -102,6 +102,12 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
*/
|
||||
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
||||
{
|
||||
$this->setMetadataBag($metaBag);
|
||||
|
||||
if (\PHP_SESSION_ACTIVE === session_status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options += array(
|
||||
// disable by default because it's managed by HeaderBag (if used)
|
||||
'cache_limiter' => '',
|
||||
@ -110,7 +116,6 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
|
||||
session_register_shutdown();
|
||||
|
||||
$this->setMetadataBag($metaBag);
|
||||
$this->setOptions($options);
|
||||
$this->setSaveHandler($handler);
|
||||
}
|
||||
|
@ -242,4 +242,24 @@ class NativeSessionStorageTest extends TestCase
|
||||
$this->assertSame($id, $storage->getId(), 'Same session ID after restarting');
|
||||
$this->assertSame(7, $storage->getBag('attributes')->get('lucky'), 'Data still available');
|
||||
}
|
||||
|
||||
public function testCanCreateNativeSessionStorageWhenSessionAlreadyStarted()
|
||||
{
|
||||
session_start();
|
||||
$this->getStorage();
|
||||
|
||||
// Assert no exception has been thrown by `getStorage()`
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testSetSessionOptionsOnceSessionStartedIsIgnored()
|
||||
{
|
||||
session_start();
|
||||
$this->getStorage(array(
|
||||
'name' => 'something-else',
|
||||
));
|
||||
|
||||
// Assert no exception has been thrown by `getStorage()`
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user