Fix duplicate session_set_save_handler call from handler instantiation.

This commit is contained in:
Pascal Woerde 2019-11-26 13:39:22 +01:00
parent d2e1681eb8
commit 2affcdfb00
No known key found for this signature in database
GPG key ID: F570D8D1F32A661D

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;