Skip to content

Commit

Permalink
Fix #27011: Session ini_set bug
Browse files Browse the repository at this point in the history
  • Loading branch information
e-moe committed Apr 27, 2018
1 parent 1d170f9 commit 7a61d31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Session/Storage/NativeSessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,21 @@ public function setOptions(array $options)
}

$validOptions = array_flip(array(
'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cache_expire', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cookie_lifetime', 'cookie_path', 'cookie_secure',
'entropy_file', 'entropy_length', 'gc_divisor',
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
'hash_function', 'lazy_write', 'name', 'referer_check',
'serialize_handler', 'use_strict_mode', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags',
'upload_progress.freq', 'upload_progress.min_freq', 'url_rewriter.tags',
'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
));

foreach ($options as $key => $value) {
if (isset($validOptions[$key])) {
ini_set('session.'.$key, $value);
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions Tests/Session/Storage/NativeSessionStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,23 @@ public function testCookieOptions()
$this->assertEquals($options, $gco);
}

public function testSessionOptions()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM is not handled in this test case.');
}

$options = array(
'url_rewriter.tags' => 'a=href',
'cache_expire' => '200',
);

$this->getStorage($options);

$this->assertSame('a=href', ini_get('url_rewriter.tags'));
$this->assertSame('200', ini_get('session.cache_expire'));
}

/**
* @expectedException \InvalidArgumentException
*/
Expand Down

0 comments on commit 7a61d31

Please sign in to comment.