Skip to content

Commit 0b36e77

Browse files
committed
Work around edge case combination of PHP 7.2+ with old ICU version
This is an alternative, simpler approach to #1834.
1 parent c5280ae commit 0b36e77

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

includes/class-amp-http.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ public static function get_amp_cache_hosts() {
203203
*/
204204
foreach ( $domains as $domain ) {
205205
if ( function_exists( 'idn_to_utf8' ) ) {
206-
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && defined( 'INTL_IDNA_VARIANT_UTS46' ) ) {
207-
$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
208-
} else {
209-
$domain = idn_to_utf8( $domain );
210-
}
206+
// The third parameter is set explicitly to prevent issues with newer PHP versions compiled with and old ICU version.
207+
// phpcs:ignore PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated
208+
$domain = idn_to_utf8( $domain, IDNA_DEFAULT, defined( 'INTL_IDNA_VARIANT_UTS46' ) ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003 );
211209
}
212210
$subdomain = str_replace( '-', '--', $domain );
213211
$subdomain = str_replace( '.', '-', $subdomain );

0 commit comments

Comments
 (0)