diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php index 366d81501375..bc642cb08286 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * MemcachedSessionStorage. @@ -21,7 +21,7 @@ * * @author Drak */ -class MemcachedSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface +class MemcachedSessionHandler implements \SessionHandlerInterface { /** * Memcached driver. @@ -63,8 +63,6 @@ public function __construct(\Memcached $memcached, array $memcachedOptions = arr $this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s'); $this->memcachedOptions = $memcachedOptions; - - parent::__construct($options); } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php index eca342ec372e..5acf004d1502 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * NativeFileSessionStorage. @@ -18,42 +18,24 @@ * * @author Drak */ -class NativeFileSessionStorage extends AbstractSessionStorage +class NativeFileSessionHandler extends NativeSessionHandler { - /** - * @var string - */ - private $savePath; - /** * Constructor. * - * @param string $savePath Path of directory to save session files. - * @param array $options Session configuration options. - * - * @see AbstractSessionStorage::__construct() + * @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP. */ - public function __construct($savePath = null, array $options = array()) + public function __construct($savePath = null) { if (null === $savePath) { - $savePath = sys_get_temp_dir(); + $savePath = ini_get('session.save_path'); } - if (!is_dir($savePath)) { + if ($savePath && !is_dir($savePath)) { mkdir($savePath, 0777, true); } - $this->savePath = $savePath; - - parent::__construct($options); - } - - /** - * {@inheritdoc} - */ - protected function registerSaveHandlers() - { ini_set('session.save_handler', 'files'); - ini_set('session.save_path', $this->savePath); + ini_set('session.save_path', $savePath); } -} +} \ No newline at end of file diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php index ec34ead6d869..beef87e965dd 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * NativeMemcacheSessionStorage. @@ -20,13 +20,8 @@ * * @author Drak */ -class NativeMemcacheSessionStorage extends AbstractSessionStorage +class NativeMemcacheSessionHandler extends NativeSessionHandler { - /** - * @var string - */ - private $savePath; - /** * Constructor. * @@ -41,17 +36,14 @@ public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', ar throw new \RuntimeException('PHP does not have "memcache" session module registered'); } - $this->savePath = $savePath; - parent::__construct($options); - } + if (null === $savePath) { + $savePath = ini_get('session.save_path'); + } - /** - * {@inheritdoc} - */ - protected function registerSaveHandlers() - { ini_set('session.save_handler', 'memcache'); - ini_set('session.save_path', $this->savePath); + ini_set('session.save_path', $savePath); + + $this->setOptions($options); } /** @@ -73,7 +65,5 @@ protected function setOptions(array $options) ini_set($key, $value); } } - - parent::setOptions($options); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php index e923f34030d5..11f6790aefba 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * NativeMemcachedSessionStorage. @@ -20,13 +20,8 @@ * * @author Drak */ -class NativeMemcachedSessionStorage extends AbstractSessionStorage +class NativeMemcachedSessionHandler extends NativeSessionHandler { - /** - * @var string - */ - private $savePath; - /** * Constructor. * @@ -41,17 +36,14 @@ public function __construct($savePath = '127.0.0.1:11211', array $options = arra throw new \RuntimeException('PHP does not have "memcached" session module registered'); } - $this->savePath = $savePath; - parent::__construct($options); - } + if (null === $savePath) { + $savePath = ini_get('session.save_path'); + } - /** - * {@inheritdoc} - */ - protected function registerSaveHandlers() - { ini_set('session.save_handler', 'memcached'); - ini_set('session.save_path', $this->savePath); + ini_set('session.save_path', $savePath); + + $this->setOptions($options); } /** @@ -72,7 +64,6 @@ protected function setOptions(array $options) ini_set($key, $value); } } - - parent::setOptions($options); } + } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php index 4c528b0dd745..4f383efb054d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * NativeSqliteSessionStorage. @@ -18,38 +18,30 @@ * * @author Drak */ -class NativeSqliteSessionStorage extends AbstractSessionStorage +class NativeSqliteSessionHandler extends NativeSessionHandler { - /** - * @var string - */ - private $dbPath; - /** * Constructor. * - * @param string $dbPath Path to SQLite database file. - * @param array $options Session configuration options. + * @param string $savePath Path to SQLite database file itself. + * @param array $options Session configuration options. * * @see AbstractSessionStorage::__construct() */ - public function __construct($dbPath, array $options = array()) + public function __construct($savePath, array $options = array()) { if (!extension_loaded('sqlite')) { throw new \RuntimeException('PHP does not have "sqlite" session module registered'); } - $this->dbPath = $dbPath; - parent::__construct($options); - } + if (null === $savePath) { + $savePath = ini_get('session.save_path'); + } - /** - * {@inheritdoc} - */ - protected function registerSaveHandlers() - { ini_set('session.save_handler', 'sqlite'); - ini_set('session.save_path', $this->dbPath); + ini_set('session.save_path', $savePath); + + $this->setOptions($options); } /** @@ -66,7 +58,5 @@ protected function setOptions(array $options) ini_set($key, $value); } } - - parent::setOptions($options); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php index 8f45a6eff277..0839622aeaa7 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\HttpFoundation\Session\Storage; +namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** * NullSessionStorage. @@ -20,7 +20,7 @@ * * @api */ -class NullSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface +class NullSessionHandler implements \SessionHandlerInterface { /** * {@inheritdoc}