{HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage

Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)".  This patch applies the first fix only if the session store is "files"

{HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage

Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)".  This patch applies the first fix only if the session store is "files"
This commit is contained in:
Tom Avery 2013-08-16 15:52:21 -04:00 committed by Fabien Potencier
parent bd4488b5c8
commit 99adcf1f6a
1 changed files with 9 additions and 7 deletions

View File

@ -208,13 +208,15 @@ class NativeSessionStorage implements SessionStorageInterface
$ret = session_regenerate_id($destroy);
// workaround for https://bugs.php.net/bug.php?id=61470 as suggested by David Grudl
session_write_close();
if (isset($_SESSION)) {
$backup = $_SESSION;
session_start();
$_SESSION = $backup;
} else {
session_start();
if($this->getSaveHandler()->getSaveHandlerName() === 'files') {
session_write_close();
if (isset($_SESSION)) {
$backup = $_SESSION;
session_start();
$_SESSION = $backup;
} else {
session_start();
}
}
return $ret;