From 4388932682fb3384bd37213f2749fc4e09b13fb2 Mon Sep 17 00:00:00 2001 From: Saskia Date: Sun, 20 Jan 2019 07:35:32 +0100 Subject: [PATCH 1/5] Update class-amp-http.php In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely lines 208 - 212 fixed --- includes/class-amp-http.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index bc103705d53..397b5b5ca5e 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -205,6 +205,11 @@ public static function get_amp_cache_hosts() { 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 if( version_compare( PHP_VERSION, '7.2', '==' ) || version_compare( PHP_VERSION, '7.3', '==' ) ){ + /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely */ + $variant = INTL_IDNA_VARIANT_UTS46; + $options = IDNA_DEFAULT; + $domain = idn_to_utf8( $domain, $options, $variant ); } else { $domain = idn_to_utf8( $domain ); } From 4f428c22626cea4562d49ff35b91fb6dde30d443 Mon Sep 17 00:00:00 2001 From: Saskia Date: Sun, 20 Jan 2019 08:19:40 +0100 Subject: [PATCH 2/5] try matching phpcs --- includes/class-amp-http.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index 397b5b5ca5e..6f97c211e11 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -205,8 +205,8 @@ public static function get_amp_cache_hosts() { 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 if( version_compare( PHP_VERSION, '7.2', '==' ) || version_compare( PHP_VERSION, '7.3', '==' ) ){ - /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely */ + } elseif ( version_compare( PHP_VERSION, '7.2', '==' ) || version_compare( PHP_VERSION, '7.3', '==' ) ) { + /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely. This may be reverted when php 7.4 is commonly used and idn_to_utf8 can be used in its default mode without warnings. */ $variant = INTL_IDNA_VARIANT_UTS46; $options = IDNA_DEFAULT; $domain = idn_to_utf8( $domain, $options, $variant ); From 9687602ddd48a259d6714841706896e0cc7bc652 Mon Sep 17 00:00:00 2001 From: Saskia Date: Sun, 20 Jan 2019 09:06:23 +0100 Subject: [PATCH 3/5] phpcs equals sign missing 1 space char line 212: warning - Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space (Generic.Formatting.MultipleStatementAlignment.NotSameWarning) --- includes/class-amp-http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index 6f97c211e11..e81efe03fa6 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -209,7 +209,7 @@ public static function get_amp_cache_hosts() { /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely. This may be reverted when php 7.4 is commonly used and idn_to_utf8 can be used in its default mode without warnings. */ $variant = INTL_IDNA_VARIANT_UTS46; $options = IDNA_DEFAULT; - $domain = idn_to_utf8( $domain, $options, $variant ); + $domain = idn_to_utf8( $domain, $options, $variant ); } else { $domain = idn_to_utf8( $domain ); } From 53a7b874d5140e06281ac95ce5edfa5bb1896820 Mon Sep 17 00:00:00 2001 From: Saskia Date: Wed, 23 Jan 2019 09:59:17 +0100 Subject: [PATCH 4/5] assure inclusion of patch versions 7.2.x and 7.3.x --- includes/class-amp-http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index e81efe03fa6..235e2fffb3c 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -205,7 +205,7 @@ public static function get_amp_cache_hosts() { 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 - } elseif ( version_compare( PHP_VERSION, '7.2', '==' ) || version_compare( PHP_VERSION, '7.3', '==' ) ) { + } elseif ( version_compare( PHP_VERSION, '7.2', '>=' ) && version_compare( PHP_VERSION, '7.4', '<' ) ) { /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely. This may be reverted when php 7.4 is commonly used and idn_to_utf8 can be used in its default mode without warnings. */ $variant = INTL_IDNA_VARIANT_UTS46; $options = IDNA_DEFAULT; From 5e8dece935911a17e0022b575bb05d4cd62f9171 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 23 Jan 2019 10:00:15 +0100 Subject: [PATCH 5/5] Update includes/class-amp-http.php Co-Authored-By: s-a-s-k-i-a --- includes/class-amp-http.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/class-amp-http.php b/includes/class-amp-http.php index 235e2fffb3c..8c27a2617e6 100644 --- a/includes/class-amp-http.php +++ b/includes/class-amp-http.php @@ -206,7 +206,11 @@ public static function get_amp_cache_hosts() { 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 } elseif ( version_compare( PHP_VERSION, '7.2', '>=' ) && version_compare( PHP_VERSION, '7.4', '<' ) ) { - /* In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. Thus we must set the variant explicitely. This may be reverted when php 7.4 is commonly used and idn_to_utf8 can be used in its default mode without warnings. */ + /* + * In PHP 7.2/7.3 calling idn_to_* functions with default arguments throws a warning. + * Thus we must set the variant explicitly. This may be reverted when PHP 7.4 is commonly used and + * idn_to_utf8 can be used in its default mode without warnings. + */ $variant = INTL_IDNA_VARIANT_UTS46; $options = IDNA_DEFAULT; $domain = idn_to_utf8( $domain, $options, $variant );