diff --git a/plugins/woocommerce/changelog/47842-update-increase-timeout-for-connect-flow b/plugins/woocommerce/changelog/47842-update-increase-timeout-for-connect-flow new file mode 100644 index 0000000000000..847f4458d6ce5 --- /dev/null +++ b/plugins/woocommerce/changelog/47842-update-increase-timeout-for-connect-flow @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Increase connection timeout to 30 seconds for the requests in WCCOM connection flow \ No newline at end of file diff --git a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php index 158e5a22fc0ad..e35057b4c6b49 100644 --- a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php +++ b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php @@ -33,7 +33,7 @@ class WC_Helper { * @return string The absolute path to the view file. */ public static function get_view_filename( $view ) { - return dirname( __FILE__ ) . "/views/$view"; + return __DIR__ . "/views/$view"; } /** @@ -119,7 +119,7 @@ public static function render_helper_output() { $subscriptions_list_data = self::get_subscription_list_data(); $subscriptions = array_filter( $subscriptions_list_data, - function( $subscription ) { + function ( $subscription ) { return ! empty( $subscription['product_key'] ); } ); @@ -362,9 +362,9 @@ function( $subscription ) { */ public static function add_utm_params_to_url_for_subscription_link( $url, $utm_content ) { $utm_params = 'utm_source=subscriptionsscreen&' . - 'utm_medium=product&' . - 'utm_campaign=wcaddons&' . - 'utm_content=' . $utm_content; + 'utm_medium=product&' . + 'utm_campaign=wcaddons&' . + 'utm_content=' . $utm_content; // there are already some URL parameters if ( strpos( $url, '?' ) ) { @@ -879,7 +879,8 @@ private static function _helper_auth_return() { $request = WC_Helper_API::post( 'oauth/access_token', array( - 'body' => array( + 'timeout' => 30, + 'body' => array( 'request_token' => wp_unslash( $_GET['request_token'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 'home_url' => home_url(), ), @@ -1634,7 +1635,7 @@ public static function get_subscription_list_data() { // Sort subscriptions by name and expiration date. usort( $subscriptions, - function( $a, $b ) { + function ( $a, $b ) { $compare_value = strcasecmp( $a['product_name'], $b['product_name'] ); if ( 0 === $compare_value ) { return strcasecmp( $a['expires'], $b['expires'] ); @@ -1954,7 +1955,7 @@ public static function deactivated_plugin( $filename ) { ); if ( wp_remote_retrieve_response_code( $deactivation_response ) === 200 ) { - $deactivated++; + ++$deactivated; /** * Fires when the Helper activates a product successfully. @@ -2027,7 +2028,7 @@ private static function _get_extensions_update_notice() { $product_id = $data['_product_id']; if ( version_compare( $updates[ $product_id ]['version'], $data['Version'], '>' ) ) { - $available++; + ++$available; } } @@ -2081,6 +2082,7 @@ public static function _flush_authentication_cache() { 'oauth/me', array( 'authenticated' => true, + 'timeout' => 30, ) );