8000 Refactor SessionStorage to NativeSessionStorage. · symfony/symfony@7f33b33 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f33b33

Browse files
author
Drak
committed
Refactor SessionStorage to NativeSessionStorage.
Native here refers to the fact the session storage interacts with real PHP sessions.
1 parent b12ece0 commit 7f33b33

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
316316
$this->addClassesToCompile(array(
317317
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
318318
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',
319-
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorage',
319+
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage',
320320
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\NativeSessionHandler',
321321
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\AbstractProxy',
322322
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\SessionHandlerProxy',

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
99
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag</parameter>
1010
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
11-
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\SessionStorage</parameter>
11+
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage</parameter>
1212
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
1313
<parameter key="session.handler.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler</parameter>
1414
& 8000 lt;parameter key="session_listener.class">Symfony\Bundle\FrameworkBundle\EventListener\SessionListener</parameter>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
1818
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
1919
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
20-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
20+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
2121

2222
/**
2323
* Session.
@@ -45,7 +45,7 @@ class Session implements SessionInterface
4545
*/
4646
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
4747
{
48-
$this->storage = $storage ?: new SessionStorage();
48+
$this->storage = $storage ?: new NativeSessionStorage();
4949
$this->registerBag($attributes ?: new AttributeBag());
5050
$this->registerBag($flashes ?: new FlashBag());
5151
}

src/Symfony/Component/HttpFoundation/Session/Storage/SessionStorage.php renamed to src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @author Drak <drak@zikula.org>
2323
*/
24-
class SessionStorage implements SessionStorageInterface
24+
class NativeSessionStorage implements SessionStorageInterface
2525
{
2626
/**
2727
* Array of SessionBagInterface

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
44

55
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
6-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
6+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
77

88
/**
99
* Test class for NativeFileSessionHandler.
@@ -16,7 +16,7 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase
1616
{
1717
public function testConstruct()
1818
{
19-
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
19+
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
2020

2121
if (version_compare(phpversion(), '5.4.0', '<')) {
2222
$this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
@@ -33,7 +33,7 @@ public function testConstruct()
3333
public function testConstructDefault()
3434
{
3535
$path = ini_get('session.save_path');
36-
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());
36+
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());
3737

3838
$this->assertEquals($path, ini_get('session.save_path'));
3939
}

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
44

55
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcacheSessionHandler;
6-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
6+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
77

88
/**
99
* Test class for NativeMemcacheSessionHandler.
@@ -20,7 +20,7 @@ public function testSaveHandlers()
2020
$this->markTestSkipped('Skipped tests SQLite extension is not present');
2121
}
2222

23-
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0'));
23+
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0'));
2424

2525
if (version_compare(phpversion(), '5.4.0', '<')) {
2626
$this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName());

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
44

55
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcachedSessionHandler;
6-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
6+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
77

88
/**
99
* Test class for NativeMemcachedSessionHandler.
@@ -23,7 +23,7 @@ public function testSaveHandlers()
2323
// test takes too long if memcached server is not running
2424
ini_set('memcached.sess_locking', '0');
2525

26-
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211'));
26+
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211'));
2727

2828
if (version_compare(phpversion(), '5.4.0', '<')) {
2929
$this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName());

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
44

55
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSqliteSessionHandler;
6-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
6+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
77

88
/**
99
* Test class for NativeSqliteSessionStorage.
@@ -20,7 +20,7 @@ public function testSaveHandlers()
2020
$this->markTestSkipped('Skipped tests SQLite extension is not present');
2121
}
2222

23-
$storage = new SessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db'));
23+
$storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db'));
2424

2525
if (version_compare(phpversion(), '5.4.0', '<')) {
2626
$this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName());

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage\Handler;
44
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
5-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
5+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
66
use Symfony\Component\HttpFoundation\Session\Session;
77

88
/**
@@ -42,7 +42,7 @@ public function testNothingIsPersisted()
4242

4343
public function getStorage()
4444
{
45-
return new SessionStorage(array(), new NullSessionHandler());
45+
return new NativeSessionStorage(array(), new NullSessionHandler());
4646
}
4747
}
4848

tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/SessionStorageTest.php renamed to tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/NativeSessionStorageTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Symfony\Tests\Component\HttpFoundation\Session\Storage;
44

5-
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorage;
5+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
66
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
77
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NullSessionHandler;
88
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
@@ -17,14 +17,14 @@
1717
*
1818
* @runTestsInSeparateProcesses
1919
*/
20-
class SessionStorageTest extends \PHPUnit_Framework_TestCase
20+
class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
2121
{
2222
/**
23-
* @return AbstractSessionStorage
23+
* @return NativeSessionStorage
2424
*/
2525
protected function getStorage(array $options = array())
2626
{
27-
$storage = new SessionStorage($options);
27+
$storage = new NativeSessionStorage($options);
2828
$storage->registerBag(new AttributeBag);
2929

3030
return $storage;
@@ -82,15 +82,15 @@ public function testDefaultSessionCacheLimiter()
8282
{
8383
ini_set('session.cache_limiter', 'nocache');
8484

85-
$storage = new SessionStorage();
85+
$storage = new NativeSessionStorage();
8686
$this->assertEquals('', ini_get('session.cache_limiter'));
8787
}
8888

8989
public function testExplicitSessionCacheLimiter()
9090
{
9191
ini_set('session.cache_limiter', 'nocache');
9292

93-
$storage = new SessionStorage(array('cache_limiter' => 'public'));
93+
$storage = new NativeSessionStorage(array('cache_limiter' => 'public'));
9494
$this->assertEquals('public', ini_get('session.cache_limiter'));
9595
}
9696

0 commit comments

Comments
 (0)
0