[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Tue, 17 Nov 2026 20:18:45 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143782@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Date: 2026-11-17T21:17:31+01:00 Commit: https://github.com/php/php-src/commit/37d40d195c34b65b0057459f9a4c175ff66a719d Raw diff: https://github.com/php/php-src/commit/37d40d195c34b65b0057459f9a4c175ff66a719d.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/posix, ext/sockets: Reset the last error at the end of a request (#25532) Changed paths: A ext/posix/tests/posix_get_last_error_request_scope.phpt A ext/sockets/tests/socket_last_error_request_scope.phpt M NEWS M ext/posix/posix.c M ext/sockets/sockets.c Diff: diff --git a/NEWS b/NEWS index a6f74d967785..57b95d47b2e0 100644 --- a/NEWS +++ b/NEWS @@ -100,10 +100,18 @@ PHP NEWS . Fixed \C being allowed in patterns enabling UTF mode with (*UTF) instead of the u modifier. (Jorg Sowa) +- POSIX: + . Fixed bug GH-25530 (posix_get_last_error() returns an error from a + previous request). (Artem Ukrainskiy) + - SOAP: . Fixed bug GH-25267 (NULL dereference in to_xml_any() with integer key). (lazerg) +- Sockets: + . Fixed bug GH-25530 (socket_last_error() without a socket returns an error + from a previous request). (Artem Ukrainskiy) + - Readline: . Fixed incorrect handling of non-ASCII pending_input bytes in readline_info(), which could cause readline() to return false prematurely. (Weilin Du) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index b8d2e5a21a27..a0159934ae9e 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -85,6 +85,15 @@ static PHP_MINIT_FUNCTION(posix) } /* }}} */ +/* {{{ PHP_RSHUTDOWN_FUNCTION(posix) */ +static PHP_RSHUTDOWN_FUNCTION(posix) +{ + POSIX_G(last_error) = 0; + + return SUCCESS; +} +/* }}} */ + /* {{{ posix_module_entry */ zend_module_entry posix_module_entry = { STANDARD_MODULE_HEADER, @@ -93,7 +102,7 @@ zend_module_entry posix_module_entry = { PHP_MINIT(posix), NULL, NULL, - NULL, + PHP_RSHUTDOWN(posix), PHP_MINFO(posix), PHP_POSIX_VERSION, PHP_MODULE_GLOBALS(posix), diff --git a/ext/posix/tests/posix_get_last_error_request_scope.phpt b/ext/posix/tests/posix_get_last_error_request_scope.phpt new file mode 100644 index 000000000000..65e3507cb66a --- /dev/null +++ b/ext/posix/tests/posix_get_last_error_request_scope.phpt @@ -0,0 +1,35 @@ +--TEST-- +posix_get_last_error() does not return an error from a previous request +--EXTENSIONS-- +posix +--CONFLICTS-- +server +--FILE-- +<?php +include __DIR__ . '/../../../sapi/cli/tests/php_cli_server.inc'; + +$code = <<<'PHP' +if (isset($_GET['fail'])) { + var_dump(posix_kill(2147483647, 0)); + var_dump(posix_get_last_error() !== 0); +} else { + var_dump(posix_get_last_error()); +} +PHP; + +$args = ['-d', 'extension_dir=' . ini_get('extension_dir')]; +$args[] = '-d'; +$args[] = 'extension=posix.' . PHP_SHLIB_SUFFIX; +if (php_ini_loaded_file()) { + $args[] = '-c'; + $args[] = php_ini_loaded_file(); +} +php_cli_server_start($code, 'index.php', $args); + +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?fail=1'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/'); +?> +--EXPECT-- +bool(false) +bool(true) +int(0) diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 4dec5fb33430..04c8abf3c840 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -546,6 +546,8 @@ static PHP_RSHUTDOWN_FUNCTION(sockets) SOCKETS_G(strerror_buf) = NULL; } + SOCKETS_G(last_error) = 0; + return SUCCESS; } /* }}} */ diff --git a/ext/sockets/tests/socket_last_error_request_scope.phpt b/ext/sockets/tests/socket_last_error_request_scope.phpt new file mode 100644 index 000000000000..4f5056165647 --- /dev/null +++ b/ext/sockets/tests/socket_last_error_request_scope.phpt @@ -0,0 +1,37 @@ +--TEST-- +socket_last_error() does not return an error from a previous request +--EXTENSIONS-- +sockets +--CONFLICTS-- +server +--FILE-- +<?php +include __DIR__ . '/../../../sapi/cli/tests/php_cli_server.inc'; + +$code = <<<'PHP' +if (isset($_GET['fail'])) { + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + // 192.0.2.1 is reserved for documentation, so it isn't a local address + var_dump(@socket_bind($socket, '192.0.2.1', 0)); + var_dump(socket_last_error() !== 0); +} else { + var_dump(socket_last_error()); +} +PHP; + +$args = ['-d', 'extension_dir=' . ini_get('extension_dir')]; +$args[] = '-d'; +$args[] = 'extension=' . (PHP_OS_FAMILY === 'Windows' ? 'php_' : '') . 'sockets.' . PHP_SHLIB_SUFFIX; +if (php_ini_loaded_file()) { + $args[] = '-c'; + $args[] = php_ini_loaded_file(); +} +php_cli_server_start($code, 'index.php', $args); + +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?fail=1'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/'); +?> +--EXPECT-- +bool(false) +bool(true) +int(0)

« previous php.cvs (#143782) next »