Bug #79705 [Opn]: Functions "intl_get_error_code", "intl_get_error_message" work incorrectly
| From: | cmb@php.net | Date: | Tue, 16 Jun 2020 11:57:32 +0000 |
| Subject: | Bug #79705 [Opn]: Functions "intl_get_error_code", "intl_get_error_message" work incorrectly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227507@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79705&edit=1
ID: 79705
Updated by: cmb@php.net
Reported by: alex dot vl dot tihon at gmail dot com
Summary: Functions "intl_get_error_code",
"intl_get_error_message" work incorrectly
Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: Ubuntu 20.04 LTS
PHP Version: 7.4.7
Block user comment: N
Private report: N
New Comment:
The behavior is not specific to PHP 7.4; it works the same for PHP
7.3[1]. I don't agree that anything should be changed for BC
reasons; after all, INTL_IDNA_VARIANT_2003 is deprecated as of PHP
7.2.0, and I think you're better off to not use this for PHP 7.3
code.
[1] <https://3v4l.org/aK0Es>
Previous Comments:
------------------------------------------------------------------------
[2020-06-16 09:49:24] alex dot vl dot tihon at gmail dot com
Description:
------------
In php7.4 the functions "intl_get_error_code", "intl_get_error_message" do not
return correct error code/message despite "idn_to_ascii" returns FALSE.
The real error code can be retrieved from 'idna_info' array passed to
"idn_to_ascii" function. But "intl_get_error_code",
"intl_get_error_message" should also work for the backward compatibility.
Test script:
---------------
// PHP 7.3.x
$result=idn_to_ascii('.pm--domain.com', IDNA_DEFAULT, INTL_IDNA_VARIANT_2003);
echo intl_get_error_code(); // 66567
echo intl_get_error_message(); // idn_to_ascii: cannot convert to ASCII:
U_IDNA_ZERO_LENGTH_LABEL_ERROR
// PHP 7.4.x
$result=idn_to_ascii('.pm--domain.com.', IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $data);
echo intl_get_error_code(); // 0
echo intl_get_error_message(); // U_ZERO_ERROR
var_dump($data);
/**array(3) {
["result"]=>
string(16) ".pm--domain.com."
["isTransitionalDifferent"]=>
bool(false)
["errors"]=>
int(33)
}*/
Expected result:
----------------
echo intl_get_error_code(); // the last error code should be returned
echo intl_get_error_message(); // the last error message should be returned
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79705&edit=1