Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ PHP NEWS
. Fixed bug GH-23477 (Memory leak on duplicate native Phar manifest entries).
(Weilin Du)

- Session:
. Fixed calling SessionHandler::open() twice without an intervening
close() when re-initializing an active session. (Ilia Alshanetsky)

- SOAP:
. Fixed bug GH-23447 (Segfault when a class passed to SoapServer::setClass()
fails to initialize). (Lazizbek Ergashev)
Expand Down
4 changes: 4 additions & 0 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ static zend_result php_session_initialize(void) /* {{{ */
{
zend_string *val = NULL;

if (PS(session_status) == php_session_active) {
php_session_abort();
}

PS(session_status) = php_session_active;

if (!PS(mod)) {
Expand Down
60 changes: 60 additions & 0 deletions ext/session/tests/session_reset_handler_close.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
--TEST--
Session reset closes the save handler before reopening it
--INI--
session.use_cookies=0
session.gc_probability=0
--FILE--
<?php

class LoggingHandler implements SessionHandlerInterface
{
public function open(string $path, string $name): bool
{
$GLOBALS['calls'][] = 'open';
return true;
}
public function close(): bool
{
$GLOBALS['calls'][] = 'close';
return true;
}
public function read(string $id): string|false
{
$GLOBALS['calls'][] = 'read';
return '';
}
public function write(string $id, string $data): bool
{
$GLOBALS['calls'][] = 'write';
return true;
}
public function destroy(string $id): bool
{
$GLOBALS['calls'][] = 'destroy';
return true;
}
public function gc(int $max_lifetime): int|false
{
$GLOBALS['calls'][] = 'gc';
return 0;
}
}

$GLOBALS['calls'] = [];
session_set_save_handler(new LoggingHandler(), true);
var_dump(session_start());
var_dump(session_reset());
print_r($GLOBALS['calls']);

?>
--EXPECT--
bool(true)
bool(true)
Array
(
[0] => open
[1] => read
[2] => close
[3] => open
[4] => read
)
Loading