8000 [RFC][Session] Native storage handlers should not update the global config by vicb · Pull Request #4208 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC][Session] Native storage handlers should not update the global config #4208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Session] Native storage handlers should not update the global ini co…
…nfig
  • Loading branch information
vicb committed May 5, 2012
commit f0b0f73e02f96a9e208e1b378953bb8e808db965
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class NativeMemcacheSessionHandler extends NativeSessionHandler
* Constructor.
*
* @param string $savePath Path of memcache server.
* @param array $options Session configuration options.
* @param array $options Memcache ini values
*
* @throws \RuntimeException If memcache is not available
*/
public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', array $options = array())
{
Expand All @@ -45,24 +47,16 @@ public function __construct($savePath = 'tcp://127.0.0.1:11211?persistent=0', ar
}

/**
* Set any memcached ini values.
* Set any memcache ini values.
*
* @param array $options Memcache 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);
}
if (isset($options['memcache.session_redundancy'])) {
ini_set('memcache.session_redundancy', $options['memcache.session_redundancy']);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ 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.
* @param array $options Memcached ini values
*
* @throws \RuntimeException When the memcached extension is not available
*/
public function __construct($savePath = '127.0.0.1:11211', array $options = array())
{
Expand All @@ -47,15 +49,16 @@ public function __construct($savePath = '127.0.0.1:11211', array $options = arra
/**
* Set any memcached ini values.
*
* @param array $options 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',
'memcached.sess_locking',
'memcached.sess_lock_wait',
'memcached.sess_prefix'
));

foreach ($options as $key => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class NativeSqliteSessionHandler extends NativeSessionHandler
* Constructor.
*
* @param string $savePath Path to SQLite database file itself.
* @param array $options Session configuration options.
*
* @throws \RuntimeException When the sqlite extension is not available
*/
public function __construct($savePath, array $options = array())
public function __construct($savePath)
{
if (!extension_loaded('sqlite')) {
throw new \RuntimeException('PHP does not have "sqlite" session module registered');
Expand All @@ -38,21 +39,5 @@ public function __construct($savePath, array $options = array())

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);
}
}
}
}
0