[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Tim Düsterhus | Date: | Tue, 17 Nov 2026 20:19:18 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143783@lists.php.net to get a copy of this message | ||
Author: Tim Düsterhus (TimWolla)
Date: 2026-11-17T21:18:49+01:00
Commit: https://github.com/php/php-src/commit/b81d0707f8abf7df28855e28d03bab05d3e6ad5d
Raw diff: https://github.com/php/php-src/commit/b81d0707f8abf7df28855e28d03bab05d3e6ad5d.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
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 d4c0610f9780..488e93f02196 100644
--- a/NEWS
+++ b/NEWS
@@ -125,12 +125,20 @@ 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)
. Fixed bug GH-25303 (NULL encoder dereference in to_xml_list() error
message). (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 f6da93bfe8f3..856cb7888023 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)