From fb2bb65b1e7857723cc0b146413bdc0b98987262 Mon Sep 17 00:00:00 2001 From: Tobias Naumann Date: Sun, 19 Feb 2012 16:45:25 +0100 Subject: [PATCH] [HttpFoundation] Fix session.cache_limiter is not set correctly --- .../Session/Storage/AbstractSessionStorage.php | 5 +++-- .../Storage/AbstractSessionStorageTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php index 799a8187b9..968a15c1a6 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/AbstractSessionStorage.php @@ -58,6 +58,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface * but we omit 'session.' from the beginning of the keys. * * auto_start, "0" + * cache_limiter, "" * cookie_domain, "" * cookie_httponly, "" * cookie_lifetime, "0" @@ -216,7 +217,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface // Unless session.cache_limiter has been set explicitly, disable it // because this is managed by HeaderBag directly (if used). if (!isset($this->options['cache_limiter'])) { - $this->options['cache_limiter'] = 0; + $this->options['cache_limiter'] = false; } if (!isset($this->options['auto_start'])) { @@ -229,7 +230,7 @@ abstract class AbstractSessionStorage implements SessionStorageInterface foreach ($this->options as $key => $value) { if (in_array($key, array( - 'auto_start', 'cookie_domain', 'cookie_httponly', + 'auto_start', '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', diff --git a/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/AbstractSessionStorageTest.php b/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/AbstractSessionStorageTest.php index e5da0fe6d1..9f391ca825 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/AbstractSessionStorageTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/Session/Storage/AbstractSessionStorageTest.php @@ -124,4 +124,20 @@ class AbstractSessionStorageTest extends \PHPUnit_Framework_TestCase $storage = new ConcreteSessionStorage(); $this->assertNotEquals('user', ini_get('session.save_handler')); } + + public function testDefaultSessionCacheLimiter() + { + ini_set('session.cache_limiter', 'nocache'); + + $storage = new ConcreteSessionStorage(); + $this->assertEquals('', ini_get('session.cache_limiter')); + } + + public function testExplicitSessionCacheLimiter() + { + ini_set('session.cache_limiter', 'nocache'); + + $storage = new ConcreteSessionStorage(array('cache_limiter' => 'public')); + $this->assertEquals('public', ini_get('session.cache_limiter')); + } }