Skip to content

Commit

Permalink
Increase timeout for WCCOM connect flow (woocommerce#47842)
Browse files Browse the repository at this point in the history
Increase connection timeout to 30 seconds for the requests in WCCOM connection flow
  • Loading branch information
thilinah authored Jun 17, 2024
1 parent f2fd496 commit eabc599
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Increase connection timeout to 30 seconds for the requests in WCCOM connection flow
20 changes: 11 additions & 9 deletions plugins/woocommerce/includes/admin/helper/class-wc-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

/**
Expand Down Expand Up @@ -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'] );
}
);
Expand Down Expand Up @@ -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, '?' ) ) {
Expand Down Expand Up @@ -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(),
),
Expand Down Expand Up @@ -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'] );
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -2081,6 +2082,7 @@ public static function _flush_authentication_cache() {
'oauth/me',
array(
'authenticated' => true,
'timeout' => 30,
)
);

Expand Down

0 comments on commit eabc599

Please sign in to comment.