]> granicus.if.org Git - php/commitdiff
Deprecate AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES
authorviest <dev@service.viest.me>
Sat, 3 Aug 2019 15:05:56 +0000 (23:05 +0800)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 26 Aug 2019 09:33:18 +0000 (11:33 +0200)
These flags have been deprecated in glibc 2.28, so we also
deprecate them in PHP.

As we can't deprecate constants, we can only check for their use
in socket_addrinfo_lookup().

UPGRADING
ext/sockets/sockets.c
ext/sockets/tests/ai_idn_deprecation.phpt [new file with mode: 0644]

index 3e4879c6efac7d3bb865acc2a8964559ed36bfb8..0cef7fc43d160c9c108991276f277db7df6e7ed5 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -404,6 +404,11 @@ PHP 7.4 UPGRADE NOTES
         // $str = ReflectionClass::export(Foo::class, true) is:
         $str = (string) new ReflectionClass(Foo::class);
 
+- Socket:
+  . The AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES flags for
+    socket_addrinfo_lookup() are deprecated, due to an upstream deprecation in
+    glibc.
+
 - Standard:
   . Passing invalid characters to ''base_convert()'', ''bindec()'', ''octdec()''
     and ''hexdec()'' will now generate a deprecation notice. The result will
index 18c124740a5ee93e88cb8955653ed5dc8dd0a368..21538e92e10f9104fd89e178907ad8ed2d6ced62 100644 (file)
@@ -2573,7 +2573,14 @@ PHP_FUNCTION(socket_addrinfo_lookup)
                ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zhints), key, hint) {
                        if (key) {
                                if (zend_string_equals_literal(key, "ai_flags")) {
-                                       hints.ai_flags = zval_get_long(hint);
+                                       zend_long flags = zval_get_long(hint);
+#if HAVE_AI_IDN
+                                       if (flags & (AI_IDN_ALLOW_UNASSIGNED | AI_IDN_USE_STD3_ASCII_RULES)) {
+                                               php_error_docref(NULL, E_DEPRECATED,
+                                                       "AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES are deprecated");
+                                       }
+#endif
+                                       hints.ai_flags = flags;
                                } else if (zend_string_equals_literal(key, "ai_socktype")) {
                                        hints.ai_socktype = zval_get_long(hint);
                                } else if (zend_string_equals_literal(key, "ai_protocol")) {
diff --git a/ext/sockets/tests/ai_idn_deprecation.phpt b/ext/sockets/tests/ai_idn_deprecation.phpt
new file mode 100644 (file)
index 0000000..02a6965
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES are deprecated
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) die('skip The sockets extension is not loaded');
+if (!defined('AI_IDN_ALLOW_UNASSIGNED')) die('skip AI_IDN_ALLOW_UNASSIGNED not defined');
+?>
+--FILE--
+<?php
+$addrinfo = socket_addrinfo_lookup('127.0.0.1', 2000, array(
+    'ai_family' => AF_INET,
+    'ai_socktype' => SOCK_DGRAM,
+    'ai_flags' => AI_IDN_ALLOW_UNASSIGNED,
+));
+var_dump(socket_addrinfo_connect($addrinfo[0]));
+echo "Done";
+--EXPECTF--
+Deprecated: socket_addrinfo_lookup(): AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES are deprecated in %s on line %d
+resource(%d) of type (Socket)
+Done