Issues with php7.2 and idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated
terryupton opened this issue · comments
Currently getting deprecated issues and breakages when using this package with PHP7.2
Looks like it is down to deprecated the INTL_IDNA_VARIANT_2003 which is still used as the default in PHP7.2.
https://www.php.net/manual/en/migration72.deprecated.php
INTL_IDNA_VARIANT_2003 variant ¶
The Intl extension has deprecated the INTL_IDNA_VARIANT_2003 variant, which is currently being used as the default for idn_to_ascii() and idn_to_utf8(). PHP 7.4 will see these defaults changed to INTL_IDNA_VARIANT_UTS46, and the next major version of PHP will remove INTL_IDNA_VARIANT_2003 altogether.
I believe the issue is at lines 111 inside StringUtils.php
public static function idnToAscii($domain)
{
// INTL_IDNA_VARIANT_UTS46 defined PHP 5.4.0 or later
if (defined('INTL_IDNA_VARIANT_UTS46')) {
return idn_to_ascii($domain, IDNA_ALLOW_UNASSIGNED, INTL_IDNA_VARIANT_UTS46);
}
return idn_to_ascii($domain, IDNA_ALLOW_UNASSIGNED);
}
These might be of use?
ezyang/htmlpurifier#163
https://aaronparecki.com/2018/02/06/9/
The presented code is convert to ascii from idn using INTL_IDNA_VARIANT_UTS46
if NTL_IDNA_VARIANT_UTS46
is defined. This code is corresponded to the deprecation of INTL_IDNA_VARIANT_2003
.
I think the cause of the error is that INTL_IDNA_VARIANT_UTS46
is not defined.
The PHP manual states that INTL_IDNA_VARIANT_UTS46
can be used with ICU 4.6 or later, so check the ICU version of the server.
I found that ICU4.2 is used by default for RHEL/CentOS 6.
If you are using RHEL/CentOS 6, installing PHP from the remi repository is the best choice. If you use remi, you can use the new ICU with RHEL/CentOS 6.