Bug #79705 [Com]: Functions "intl_get_error_code", "intl_get_error_message" work incorrectly

From: Date: Tue, 16 Jun 2020 16:08:15 +0000
Subject: Bug #79705 [Com]: 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-227513@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 Comment by: atikhonov at plesk dot com 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: Maybe I mislead you with the usage of the "INTL_IDNA_VARIANT_2003" constant. But the issue is in the incorrect behaviour of "intl_get_error_code", "intl_get_error_message" for PHP 7.4.x if "idn_to_ascii" function returns "FALSE". Please, take a look: https://3v4l.org/0ekbB For PHP 7.4.x "idn_to_ascii" function returns FALSE. But at the same time the "intl_get_error_code" returns code 0 and "intl_get_error_message" returns U_ZERO_ERROR. I think it is incorrect. The last error code/message should be returned as for PHP 7.2.0 - 7.2.31, 7.3.10 - 7.3.19 Previous Comments: ------------------------------------------------------------------------ [2020-06-16 11:57:32] cmb@php.net 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> ------------------------------------------------------------------------ [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

« previous php.bugs (#227513) next »