[php-src] master: Merge branch 'PHP-8.6'

From: Date: Tue, 17 Nov 2026 20:20:42 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143784@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Date: 2026-11-17T21:20:36+01:00 Commit: https://github.com/php/php-src/commit/3c6d39b68df943e78d4f70043e94c8453cfb6347 Raw diff: https://github.com/php/php-src/commit/3c6d39b68df943e78d4f70043e94c8453cfb6347.diff Merge branch 'PHP-8.6' * PHP-8.6: 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 ext/posix/posix.c M ext/sockets/sockets.c Diff: diff --git a/ext/posix/posix.c b/ext/posix/posix.c index f217199118db..78ffbe5a2875 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -83,6 +83,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, @@ -91,7 +100,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 c58aa0936285..423be987e03c 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -534,6 +534,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 (#143784) next »