HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/server/php/83/src/ext/session/tests/user_session_module/session_set_save_handler_multiple.phpt
--TEST--
session_set_save_handler(): optional closures not set again in second call
--INI--
session.use_strict_mode=1
session.name=PHPSESSID
session.serialize_handler=php_serialize
--EXTENSIONS--
session
--FILE--
<?php

$data = [];

ob_start();
function open($path, $name): bool {
    echo 'Open', "\n";
    return true;
}
function create_sid(): string {
    echo 'Create SID OLD', "\n";
    return 'OLD_ID';
}
function read($key): string|false {
    echo 'Read', "\n";
    global $data;
    return serialize($data);
}
function write($key, $val): bool {
    echo 'Write', "\n";
    global $data;
    $data[$key] = $val;
    return true;
}
function close(): bool {
    echo 'Close', "\n";
    return true;
}
function destroy($id): bool {
    echo 'Destroy', "\n";
    return true;
}
function gc($lifetime): bool {
    return true;
}
function createSid(): string {
    echo 'Create SID NEW', "\n";
    return 'NEW_ID';
}
function validateId($key): bool {
    echo 'Validate ID', "\n";
    return true;
}
function updateTimestamp($key, $data): bool {
    echo 'Update Timestamp', "\n";
    return true;
}

session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc', 'create_sid', 'validateId', 'updateTimestamp');
session_start();

$_SESSION['foo'] = "hello";

session_write_close();
session_unset();

echo "New handlers:\n";
session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
session_start();
var_dump($_SESSION);
$_SESSION['bar'] = "world";
session_write_close();

ob_end_flush();
?>
--EXPECT--
Open
Create SID OLD
Read
Write
Close
New handlers:
Open
Validate ID
Read
array(1) {
  ["OLD_ID"]=>
  string(28) "a:1:{s:3:"foo";s:5:"hello";}"
}
Write
Close