Skip to content

Commit

Permalink
Work around edge case combination of PHP 7.2+ with old ICU version
Browse files Browse the repository at this point in the history
This is an alternative, simpler approach to #1834.
  • Loading branch information
swissspidy committed Mar 18, 2019
1 parent c5280ae commit 0b36e77
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions includes/class-amp-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 0b36e77

Please sign in to comment.