diff options
author | viest <dev@service.viest.me> | 2019-08-03 23:05:56 +0800 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-26 11:33:18 +0200 |
commit | 5703943081fc24d555e572edf507a05702974d98 (patch) | |
tree | cee20e11b23ce94b5c5510c73b7789ede5a2c12f | |
parent | 774cdb1d5909b150fcb60fed7875a3c346ad9543 (diff) | |
download | php-git-5703943081fc24d555e572edf507a05702974d98.tar.gz |
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().
-rw-r--r-- | UPGRADING | 5 | ||||
-rw-r--r-- | ext/sockets/sockets.c | 9 | ||||
-rw-r--r-- | ext/sockets/tests/ai_idn_deprecation.phpt | 20 |
3 files changed, 33 insertions, 1 deletions
@@ -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 18c124740a..21538e92e1 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 0000000000..02a6965d26 --- /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 |