From 0b36e77bec486d0d78281e73a4bf19d718aed0ea Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 18 Mar 2019 12:06:22 +0100 Subject: [PATCH] Work around edge case combination of PHP 7.2+ with old ICU version This is an alternative, simpler approach to #1834. --- includes/class-amp-http.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index 40d8d49ac66..7fd6248d007 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -203,11 +203,9 @@ public static function get_amp_cache_hosts() { */ foreach ( $domains as $domain ) { if ( function_exists( 'idn_to_utf8' ) ) { - if ( version_compare( PHP_VERSION, '5.4', '>=' ) && defined( 'INTL_IDNA_VARIANT_UTS46' ) ) { - $domain = idn_to_utf8( $domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46 ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctionParameters.idn_to_utf8_variantFound, PHPCompatibility.Constants.NewConstants.intl_idna_variant_uts46Found - } else { - $domain = idn_to_utf8( $domain ); - } + // The third parameter is set explicitly to prevent issues with newer PHP versions compiled with and old ICU version. + // phpcs:ignore PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated + $domain = idn_to_utf8( $domain, IDNA_DEFAULT, defined( 'INTL_IDNA_VARIANT_UTS46' ) ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003 ); } $subdomain = str_replace( '-', '--', $domain ); $subdomain = str_replace( '.', '-', $subdomain );