com php-src: Deprecate AI_IDN_ALLOW_UNASSIGNED and AI _IDN_USE_STD3_ASCII_RULES: UPGRADING ext/sock ets/sockets.c
ext/sockets/tests/ai_idn_deprecation.ph pt
| From: | Nikita Popov | Date: | Mon, 26 Aug 2019 09:33:18 +0000 |
| Subject: | com php-src: Deprecate AI_IDN_ALLOW_UNASSIGNED and AI _IDN_USE_STD3_ASCII_RULES: UPGRADING ext/sock ets/sockets.c ext/sockets/tests/ai_idn_deprecation.ph pt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108054@lists.php.net to get a copy of this message | ||
Commit: 5703943081fc24d555e572edf507a05702974d98
Author: viest <dev@service.viest.me> Sat, 3 Aug 2019 23:05:56 +0800
Committer: Nikita Popov <nikita.ppv@gmail.com> Mon, 26 Aug 2019 11:33:18 +0200
Parents: 774cdb1d5909b150fcb60fed7875a3c346ad9543
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5703943081fc24d555e572edf507a05702974d98
Log:
Deprecate AI_IDN_ALLOW_UNASSIGNED and AI_IDN_USE_STD3_ASCII_RULES
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().
Changed paths:
M UPGRADING
M ext/sockets/sockets.c
A ext/sockets/tests/ai_idn_deprecation.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index 3e4879c..0cef7fc 100644
--- 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
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 18c1247..21538e9 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -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
index 0000000..02a6965
--- /dev/null
+++ b/ext/sockets/tests/ai_idn_deprecation.phpt
@@ -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