Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a14a056

Browse files
committed
Fix #27011: Session ini_set bug
1 parent bf8ed0a commit a14a056

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,23 @@ public function setOptions(array $options)
340340
}
341341

342342
$validOptions = array_flip(array(
343-
'cache_limiter', 'cookie_domain', 'cookie_httponly',
343+
'cache_limiter', 'cache_expire', 'cookie_domain', 'cookie_httponly',
344344
'cookie_lifetime', 'cookie_path', 'cookie_secure',
345345
'entropy_file', 'entropy_length', 'gc_divisor',
346346
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
347347
'hash_function', 'lazy_write', 'name', 'referer_check',
348348
'serialize_handler', 'use_strict_mode', 'use_cookies',
349349
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
350350
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
351-
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags',
351+
'upload_progress.freq', 'upload_progress.min_freq', 'url_rewriter.tags',
352352
'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
353353
));
354354

355355
foreach ($options as $key => $value) {
356356
if (isset($validOptions[$key])) {
357-
ini_set('session.'.$key, $value);
357+
// All options starts with 'session.' except 'url_rewriter.tags'
358+
$name = 'url_rewriter.tags' != $key ? 'session.'.$key : $key;
359+
ini_set($name, $value);
358360
}
359361
}
360362
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ public function testCookieOptions()
183183
$this->assertEquals($options, $gco);
184184
}
185185

186+
public function testSessionOptions()
187+
{
188+
$options = array(
189+
'url_rewriter.tags' => 'a=href',
190+
'cache_expire' => 200,
191+
);
192+
193+
$this->getStorage($options);
194+
195+
$this->assertEquals('a=href', ini_get('url_rewriter.tags'));
196+
$this->assertEquals(200, ini_get('session.cache_expire'));
197+
}
198+
186199
/**
187200
* @expectedException \InvalidArgumentException
188201
*/

0 commit comments

Comments
 (0)