[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Gina Peter Banyard | Date: | Sun, 06 Sep 2026 13:02:00 +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-141089@lists.php.net to get a copy of this message | ||
Author: Gina Peter Banyard (Girgias)
Date: 2026-09-06T13:59:46+01:00
Commit: https://github.com/php/php-src/commit/8b287531b881ff9355900fa563521c8b224d6602
Raw diff: https://github.com/php/php-src/commit/8b287531b881ff9355900fa563521c8b224d6602.diff
Merge branch 'PHP-8.4' into PHP-8.5
Changed paths:
A Zend/tests/gh23232.phpt
A ext/standard/tests/network/fsockopen_timeout_out_of_range.phpt
M NEWS
M Zend/zend_execute_API.c
M ext/standard/fsock.c
M ext/standard/tests/streams/gh14780.phpt
Diff:
diff --git a/NEWS b/NEWS
index 83a6f7c6ed8b..fa7bdcceadce 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP NEWS
- Core:
. Fixed bug GH-15375 (Nested "yield from" skips items after a valid() or
next() call on the inner generator). (iliaal)
+ . Fixed bug GH-23232 (lone namespace separator asks the autoloader for an
+ empty class name). (spawnia)
. Fixed bug GH-23301 (Nested "yield from" yields a value twice when the
middle generator delegates again). (Lazizbek Ergashev)
@@ -94,6 +96,8 @@ PHP NEWS
. Fixed read buffer compaction in php_stream_filter_flush(). (crystarm)
. Fixed bug GH-22410 (Incorrect float behavior with large numbers).
(arshidkv12)
+ . Fixed GH-23338 (fsockopen()/pfsockopen() ValueError reported wrong
+ argument number for $timeout). (lacatoire)
- SimpleXML:
. Fixed writing to a dimension of the object returned by attributes() not
diff --git a/Zend/tests/gh23232.phpt b/Zend/tests/gh23232.phpt
new file mode 100644
index 000000000000..57a2e0135e8e
--- /dev/null
+++ b/Zend/tests/gh23232.phpt
@@ -0,0 +1,27 @@
+--TEST--
+GH-23232 (lone namespace separator asks the autoloader for an empty class name)
+--FILE--
+<?php
+spl_autoload_register(function (string $class): void {
+ echo "autoload: '$class'\n";
+});
+
+foreach (['::a', '\::a', '\Foo::a', 'Foo::a'] as $callable)
{
+ echo "is_callable(\"$callable\")\n";
+ var_dump(is_callable($callable));
+}
+
+var_dump(class_exists('\\'));
+?>
+--EXPECT--
+is_callable("::a")
+bool(false)
+is_callable("\::a")
+bool(false)
+is_callable("\Foo::a")
+autoload: 'Foo'
+bool(false)
+is_callable("Foo::a")
+autoload: 'Foo'
+bool(false)
+bool(false)
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 0719fcbbed1c..a74cfa759430 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1190,6 +1190,10 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name,
zend_string *
}
if (ZSTR_VAL(name)[0] == '\\') {
+ if (ZSTR_LEN(name) == 1) {
+ /* A lone namespace separator names no class, e.g. is_callable('\::method'). */
+ return NULL;
+ }
lc_name = zend_string_alloc(ZSTR_LEN(name) - 1, 0);
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1);
} else {
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index c8e6ed08e4c0..bf60f610f849 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -107,7 +107,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
efree(hashkey);
}
- zend_argument_value_error(6, "must be -1 or between 0 and " ZEND_ULONG_FMT, ((double)
PHP_TIMEOUT_ULL_MAX / 1000000.0));
+ zend_argument_value_error(5, "must be -1 or between 0 and %" PRIu64, (uint64_t)
((double) PHP_TIMEOUT_ULL_MAX / 1000000.0));
RETURN_THROWS();
} else {
#ifndef PHP_WIN32
diff --git a/ext/standard/tests/network/fsockopen_timeout_out_of_range.phpt
b/ext/standard/tests/network/fsockopen_timeout_out_of_range.phpt
new file mode 100644
index 000000000000..575db4690fb9
--- /dev/null
+++ b/ext/standard/tests/network/fsockopen_timeout_out_of_range.phpt
@@ -0,0 +1,19 @@
+--TEST--
+fsockopen() and pfsockopen(): ValueError for $timeout reports correct argument number and name
+--FILE--
+<?php
+try {
+ fsockopen('localhost', 80, $errno, $errstr, -2.0);
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+ pfsockopen('localhost', 80, $errno, $errstr, -2.0);
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+?>
+--EXPECTF--
+ValueError: fsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s
+ValueError: pfsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s
diff --git a/ext/standard/tests/streams/gh14780.phpt b/ext/standard/tests/streams/gh14780.phpt
index 064e496b1753..c0fc4e621a9d 100644
--- a/ext/standard/tests/streams/gh14780.phpt
+++ b/ext/standard/tests/streams/gh14780.phpt
@@ -31,8 +31,8 @@ try {
}
?>
--EXPECTF--
-pfsockopen(): Argument #6 must be -1 or between 0 and %s
-pfsockopen(): Argument #6 must be -1 or between 0 and %s
+pfsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s
+pfsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s
resource(%d) of type (persistent stream)
-pfsockopen(): Argument #6 must be -1 or between 0 and %s
-pfsockopen(): Argument #6 must be -1 or between 0 and %s
+pfsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s
+pfsockopen(): Argument #5 ($timeout) must be -1 or between 0 and %s