Commit ebf5029b421 for php

commit ebf5029b421aeb0c944d4316eb869b9a17d4e17f
Author: lacatoire <la.catoire@gmail.com>
Date:   Mon Oct 26 16:10:21 2026 +0100

    ext/sockets: Accept an empty packed hints array in socket_addrinfo_lookup()

    socket_addrinfo_lookup() throws a ValueError for an empty packed $hints
    (left by unset()), while [] is accepted. Skip empty hints.

    Close GH-24747

diff --git a/NEWS b/NEWS
index 2b7c0a0e6ab..6fb099bd856 100644
--- a/NEWS
+++ b/NEWS
@@ -86,6 +86,10 @@ PHP                                                                        NEWS
   . Fix trampoline leak when object construction fails for lazy object.
     (ndossche)

+- Sockets:
+  . Fixed socket_addrinfo_lookup() rejecting an empty packed hints array.
+    (lacatoire)
+
 - Streams:
   . Fixed in-place URL decoding of interned strings in the HTTP and FTP
     wrappers. (Alejandro Pacheco)
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 6aa14c06bdd..4dec5fb3343 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -2768,7 +2768,7 @@ PHP_FUNCTION(socket_addrinfo_lookup)
 #  endif
 #endif

-	if (zhints) {
+	if (zhints && zend_hash_num_elements(Z_ARRVAL_P(zhints)) > 0) {
 		if (UNEXPECTED(HT_IS_PACKED(Z_ARRVAL_P(zhints)))) {
 			zend_argument_value_error(3, "must only contain array keys \"ai_flags\", \"ai_socktype\", "
 					"\"ai_protocol\", or \"ai_family\"");
diff --git a/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt b/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
new file mode 100644
index 00000000000..6905a1bad17
--- /dev/null
+++ b/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
@@ -0,0 +1,21 @@
+--TEST--
+socket_addrinfo_lookup(): an empty packed hints array is accepted like []
+--EXTENSIONS--
+sockets
+--FILE--
+<?php
+$hints = [1];
+unset($hints[0]);
+var_dump(count($hints), $hints === []);
+var_dump(count(socket_addrinfo_lookup('127.0.0.1', '80', $hints)) === count(socket_addrinfo_lookup('127.0.0.1', '80', [])));
+try {
+    socket_addrinfo_lookup('127.0.0.1', '80', [1]);
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+int(0)
+bool(true)
+bool(true)
+ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family"