From b2cc580be7614e80d9009126937c7c24aa0741c6 Mon Sep 17 00:00:00 2001 From: Drak Date: Sat, 26 May 2012 17:21:39 +0545 Subject: [PATCH] [HttpFoundation] Removed Native*Handler session save handler classes --- .../Handler/NativeFileSessionHandler.php | 41 ----------- .../Handler/NativeMemcacheSessionHandler.php | 68 ------------------- .../Handler/NativeMemcachedSessionHandler.php | 67 ------------------ .../Handler/NativeRedisSessionHandler.php | 43 ------------ .../Storage/Handler/NativeSessionHandler.php | 24 ------- .../Handler/NativeSqliteSessionHandler.php | 58 ---------------- .../NativeMemcacheSessionHandlerTest.php | 45 ------------ .../NativeMemcachedSessionHandlerTest.php | 49 ------------- .../Handler/NativeRedisSessionHandlerTest.php | 43 ------------ .../NativeSqliteSessionHandlerTest.php | 47 ------------- 10 files changed, 485 deletions(-) delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php delete mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php delete mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php delete mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php delete mode 100644 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php deleted file mode 100644 index 422e3a79a6..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeFileSessionHandler. - * - * Native session handler using PHP's built in file storage. - * - * @author Drak - */ -class NativeFileSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP. - */ - public function __construct($savePath = null) - { - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - if ($savePath && !is_dir($savePath)) { - mkdir($savePath, 0777, true); - } - - ini_set('session.save_handler', 'files'); - ini_set('session.save_path', $savePath); - } -} diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php deleted file mode 100644 index 0b9c623558..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcacheSessionHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeMemcacheSessionHandler. - * - * Driver for the memcache session save handler provided by the memcache PHP extension. - * - * @see http://php.net/memcache - * - * @author Drak - */ -class NativeMemcacheSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of memcache server. - * @param array $options Session configuration options. - */ - public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array()) - { - if (!extension_loaded('memcache')) { - throw new \RuntimeException('PHP does not have "memcache" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'memcache'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any memcached ini values. - * - * @see http://php.net/memcache.ini - */ - protected function setOptions(array $options) - { - $validOptions = array_flip(array( - 'memcache.allow_failover', 'memcache.max_failover_attempts', - 'memcache.chunk_size', 'memcache.default_port', 'memcache.hash_strategy', - 'memcache.hash_function', 'memcache.protocol', 'memcache.redundancy', - 'memcache.session_redundancy', 'memcache.compress_threshold', - 'memcache.lock_timeout', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set($key, $value); - } - } - } -} diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php deleted file mode 100644 index ee9d75475b..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeMemcachedSessionHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeMemcachedSessionHandler. - * - * Driver for the memcached session save handler provided by the memcached PHP extension. - * - * @see http://php.net/memcached.sessions - * - * @author Drak - */ -class NativeMemcachedSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Comma separated list of servers: e.g. memcache1.example.com:11211,memcache2.example.com:11211 - * @param array $options Session configuration options. - */ - public function __construct($savePath = '127.0.0.1:11211', array $options = array()) - { - if (!extension_loaded('memcached')) { - throw new \RuntimeException('PHP does not have "memcached" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'memcached'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any memcached ini values. - * - * @see https://github.com/php-memcached-dev/php-memcached/blob/master/memcached.ini - */ - protected function setOptions(array $options) - { - $validOptions = array_flip(array( - 'memcached.sess_locking', 'memcached.sess_lock_wait', - 'memcached.sess_prefix', 'memcached.compression_type', - 'memcached.compression_factor', 'memcached.compression_threshold', - 'memcached.serializer', - )); - - foreach ($options as $key => $value) { - if (isset($validOptions[$key])) { - ini_set($key, $value); - } - } - } -} diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php deleted file mode 100644 index e60c7f6558..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeRedisSessionHandler.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeRedisSessionStorage. - * - * Driver for the redis session save handler provided by the redis PHP extension. - * - * @see https://github.com/nicolasff/phpredis - * - * @author Andrej Hudec - */ -class NativeRedisSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path of redis server. - */ - public function __construct($savePath = 'tcp://127.0.0.1:6379?persistent=0') - { - if (!extension_loaded('redis')) { - throw new \RuntimeException('PHP does not have "redis" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'redis'); - ini_set('session.save_path', $savePath); - } -} diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php deleted file mode 100644 index 1260ad0d29..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * Adds SessionHandler functionality if available. - * - * @see http://php.net/sessionhandler - */ - -if (version_compare(phpversion(), '5.4.0', '>=')) { - class NativeSessionHandler extends \SessionHandler {} -} else { - class NativeSessionHandler {} -} diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php deleted file mode 100644 index ac034c2938..0000000000 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSqliteSessionHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; - -/** - * NativeSqliteSessionHandler. - * - * Driver for the sqlite session save handler provided by the SQLite PHP extension. - * - * @author Drak - */ -class NativeSqliteSessionHandler extends NativeSessionHandler -{ - /** - * Constructor. - * - * @param string $savePath Path to SQLite database file itself. - * @param array $options Session configuration options. - */ - public function __construct($savePath, array $options = array()) - { - if (!extension_loaded('sqlite')) { - throw new \RuntimeException('PHP does not have "sqlite" session module registered'); - } - - if (null === $savePath) { - $savePath = ini_get('session.save_path'); - } - - ini_set('session.save_handler', 'sqlite'); - ini_set('session.save_path', $savePath); - - $this->setOptions($options); - } - - /** - * Set any sqlite ini values. - * - * @see http://php.net/sqlite.configuration - */ - protected function setOptions(array $options) - { - foreach ($options as $key => $value) { - if (in_array($key, array('sqlite.assoc_case'))) { - ini_set($key, $value); - } - } - } -} diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php deleted file mode 100644 index b915e59ca0..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcacheSessionHandlerTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcacheSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeMemcacheSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeMemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('memcache')) { - $this->markTestSkipped('Skipped tests memcache extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcacheSessionHandler('tcp://127.0.0.1:11211?persistent=0')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('memcache', ini_get('session.save_handler')); - } else { - $this->assertEquals('memcache', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('tcp://127.0.0.1:11211?persistent=0', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php deleted file mode 100644 index 5f65e9a0fe..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeMemcachedSessionHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeMemcachedSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeMemcachedSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeMemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('memcached')) { - $this->markTestSkipped('Skipped tests memcached extension is not present'); - } - - // test takes too long if memcached server is not running - ini_set('memcached.sess_locking', '0'); - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeMemcachedSessionHandler('127.0.0.1:11211')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('memcached', ini_get('session.save_handler')); - } else { - $this->assertEquals('memcached', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('127.0.0.1:11211', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} - diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php deleted file mode 100644 index 8a5777659d..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeRedisSessionHandlerTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeRedisSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeRedisSessionHandlerTest. - * - * @runTestsInSeparateProcesses - */ -class NativeRedisSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('redis')) { - $this->markTestSkipped('Skipped tests Redis extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeRedisSessionHandler('tcp://127.0.0.1:6379?persistent=0')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('redis', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('redis', ini_get('session.save_handler')); - } else { - $this->assertEquals('redis', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - $this->assertEquals('tcp://127.0.0.1:6379?persistent=0', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php deleted file mode 100644 index 983148e279..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSqliteSessionHandlerTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; - -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSqliteSessionHandler; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * Test class for NativeSqliteSessionHandler. - * - * @author Drak - * - * @runTestsInSeparateProcesses - */ -class NativeSqliteSessionHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testSaveHandlers() - { - if (!extension_loaded('sqlite')) { - $this->markTestSkipped('Skipped tests SQLite extension is not present'); - } - - $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeSqliteSessionHandler(sys_get_temp_dir().'/sqlite.db')); - - if (version_compare(phpversion(), '5.4.0', '<')) { - $this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('sqlite', ini_get('session.save_handler')); - } else { - $this->assertEquals('sqlite', $storage->getSaveHandler()->getSaveHandlerName()); - $this->assertEquals('user', ini_get('session.save_handler')); - } - - - $this->assertEquals(sys_get_temp_dir().'/sqlite.db', ini_get('session.save_path')); - $this->assertEquals('TESTING', ini_get('session.name')); - } -} -