Merge pull request #13947 from pascalwoerde/2.cannot-change-save-handler-when-session-is-active

Fix duplicate session_set_save_handler call from handler instantiation.
This commit is contained in:
Mark Story 2019-11-28 16:56:04 -05:00 committed by GitHub
commit 5eed56b6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -587,16 +587,18 @@ class CakeSession {
if (!empty($sessionConfig['handler']) && !isset($sessionConfig['handler']['engine'])) {
call_user_func_array('session_set_save_handler', $sessionConfig['handler']);
}
if (!empty($sessionConfig['handler']['engine']) && !headers_sent() && (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE)) {
if (!empty($sessionConfig['handler']['engine']) && !headers_sent()) {
$handler = static::_getHandler($sessionConfig['handler']['engine']);
session_set_save_handler(
array($handler, 'open'),
array($handler, 'close'),
array($handler, 'read'),
array($handler, 'write'),
array($handler, 'destroy'),
array($handler, 'gc')
);
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
session_set_save_handler(
array($handler, 'open'),
array($handler, 'close'),
array($handler, 'read'),
array($handler, 'write'),
array($handler, 'destroy'),
array($handler, 'gc')
);
}
}
Configure::write('Session', $sessionConfig);
static::$sessionTime = static::$time;