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

Appearance settings

Commit 0a064d8

Browse filesBrowse files
author
Drak
committed
[HttpFoundation] Refactor session handlers.
1 parent 2326707 commit 0a064d8
Copy full SHA for 0a064d8

File tree

Expand file treeCollapse file tree

6 files changed

+40
-89
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+40
-89
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/MemcachedSessionStorage.php
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* MemcachedSessionStorage.
@@ -21,7 +21,7 @@
2121
*
2222
* @author Drak <drak@zikula.org>
2323
*/
24-
class MemcachedSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface
24+
class MemcachedSessionHandler implements \SessionHandlerInterface
2525
{
2626
/**
2727
* Memcached driver.
@@ -63,8 +63,6 @@ public function __construct(\Memcached $memcached, array $memcachedOptions = arr
6363
$this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, isset($memcachedOptions['prefix']) ? $memcachedOptions['prefix'] : 'sf2s');
6464

6565
$this->memcachedOptions = $memcachedOptions;
66-
67-
parent::__construct($options);
6866
}
6967

7068
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.php
+8-26Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* NativeFileSessionStorage.
@@ -18,42 +18,24 @@
1818
*
1919
* @author Drak <drak@zikula.org>
2020
*/
21-
class NativeFileSessionStorage extends AbstractSessionStorage
21+
class NativeFileSessionHandler extends NativeSessionHandler
2222
{
23-
/**
24-
* @var string
25-
*/
26-
private $savePath;
27-
2823
/**
2924
* Constructor.
3025
*
31-
* @param string $savePath Path of directory to save session files.
32-
* @param array $options Session configuration options.
33-
*
34-
* @see AbstractSessionStorage::__construct()
26+
* @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP.
3527
*/
36-
public function __construct($savePath = null, array $options = array())
28+
public function __construct($savePath = null)
3729
{
3830
if (null === $savePath) {
39-
$savePath = sys_get_temp_dir();
31+
$savePath = ini_get('session.save_path');
4032
}
4133

42-
if (!is_dir($savePath)) {
34+
if ($savePath && !is_dir($savePath)) {
4335
mkdir($savePath, 0777, true);
4436
}
4537

46-
$this->savePath = $savePath;
47-
48-
parent::__construct($options);
49-
}
50-
51-
/**
52-
* {@inheritdoc}
53-
*/
54-
protected function registerSaveHandlers()
55-
{
5638
ini_set('session.save_handler', 'files');
57-
ini_set('session.save_path', $this->savePath);
39+
ini_set('session.save_path', $savePath);
5840
}
59-
}
41+
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcacheSessionStorage.php
+8-18Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* NativeMemcacheSessionStorage.
@@ -20,13 +20,8 @@
2020
*
2121
* @author Drak <drak@zikula.org>
2222
*/
23-
class NativeMemcacheSessionStorage extends AbstractSessionStorage
23+
class NativeMemcacheSessionHandler extends NativeSessionHandler
2424
{
25-
/**
26-
* @var string
27-
*/
28-
private $savePath;
29-
3025
/**
3126
* Constructor.
3227
*
@@ -41,17 +36,14 @@ public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', ar
4136
throw new \RuntimeException('PHP does not have "memcache" session module registered');
4237
}
4338

44-
$this->savePath = $savePath;
45-
parent::__construct($options);
46-
}
39+
if (null === $savePath) {
40+
$savePath = ini_get('session.save_path');
41+
}
4742

48-
/**
49-
* {@inheritdoc}
50-
*/
51-
protected function registerSaveHandlers()
52-
{
5343
ini_set('session.save_handler', 'memcache');
54-
ini_set('session.save_path', $this->savePath);
44+
ini_set('session.save_path', $savePath);
45+
46+
$this->setOptions($options);
5547
}
5648

5749
/**
@@ -73,7 +65,5 @@ protected function setOptions(array $options)
7365
ini_set($key, $value);
7466
}
7567
}
76-
77-
parent::setOptions($options);
7868
}
7969
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeMemcachedSessionStorage.php
+9-18Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* NativeMemcachedSessionStorage.
@@ -20,13 +20,8 @@
2020
*
2121
* @author Drak <drak@zikula.org>
2222
*/
23-
class NativeMemcachedSessionStorage extends AbstractSessionStorage
23+
class NativeMemcachedSessionHandler extends NativeSessionHandler
2424
{
25-
/**
26-
* @var string
27-
*/
28-
private $savePath;
29-
3025
/**
3126
* Constructor.
3227
*
@@ -41,17 +36,14 @@ public function __construct($savePath = '127.0.0.1:11211', array $options = arra
4136
throw new \RuntimeException('PHP does not have "memcached" session module registered');
4237
}
4338

44-
$this->savePath = $savePath;
45-
parent::__construct($options);
46-
}
39+
if (null === $savePath) {
40+
$savePath = ini_get('session.save_path');
41+
}
4742

48-
/**
49-
* {@inheritdoc}
50-
*/
51-
protected function registerSaveHandlers()
52-
{
5343
ini_set('session.save_handler', 'memcached');
54-
ini_set('session.save_path', $this->savePath);
44+
ini_set('session.save_path', $savePath);
45+
46+
$this->setOptions($options);
5547
}
5648

5749
/**
@@ -72,7 +64,6 @@ protected function setOptions(array $options)
7264
ini_set($key, $value);
7365
}
7466
}
75-
76-
parent::setOptions($options);
7767
}
68+
7869
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeSqliteSessionStorage.php
+11-21Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* NativeSqliteSessionStorage.
@@ -18,38 +18,30 @@
1818
*
1919
* @author Drak <drak@zikula.org>
2020
*/
21-
class NativeSqliteSessionStorage extends AbstractSessionStorage
21+
class NativeSqliteSessionHandler extends NativeSessionHandler
2222
{
23-
/**
24-
* @var string
25-
*/
26-
private $dbPath;
27-
2823
/**
2924
* Constructor.
3025
*
31-
* @param string $dbPath Path to SQLite database file.
32-
* @param array $options Session configuration options.
26+
* @param string $savePath Path to SQLite database file itself.
27+
* @param array $options Session configuration options.
3328
*
3429
* @see AbstractSessionStorage::__construct()
3530
*/
36-
public function __construct($dbPath, array $options = array())
31+
public function __construct($savePath, array $options = array())
3732
{
3833
if (!extension_loaded('sqlite')) {
3934
throw new \RuntimeException('PHP does not have "sqlite" session module registered');
4035
}
4136

42-
$this->dbPath = $dbPath;
43-
parent::__construct($options);
44-
}
37+
if (null === $savePath) {
38+
$savePath = ini_get('session.save_path');
39+
}
4540

46-
/**
47-
* {@inheritdoc}
48-
*/
49-
protected function registerSaveHandlers()
50-
{
5141
ini_set('session.save_handler', 'sqlite');
52-
ini_set('session.save_path', $this->dbPath);
42+
ini_set('session.save_path', $savePath);
43+
44+
$this->setOptions($options);
5345
}
5446

5547
/**
@@ -66,7 +58,5 @@ protected function setOptions(array $options)
6658
ini_set($key, $value);
6759
}
6860
}
69-
70-
parent::setOptions($options);
7161
}
7262
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NullSessionStorage.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\HttpFoundation\Session\Storage;
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

1414
/**
1515
* NullSessionStorage.
@@ -20,7 +20,7 @@
2020
*
2121
* @api
2222
*/
23-
class NullSessionStorage extends AbstractSessionStorage implements \SessionHandlerInterface
23+
class NullSessionHandler implements \SessionHandlerInterface
2424
{
2525
/**
2626
* {@inheritdoc}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.