From 5797d2b6393e20951eb1f078e1e218559c718209 Mon Sep 17 00:00:00 2001 From: Justin Foell Date: Thu, 29 Mar 2018 08:49:40 -0500 Subject: [PATCH] Increased API post timeout to 30 seconds Simplified access token logic --- lib/WPStrava/API.php | 1 + lib/WPStrava/Settings.php | 32 +++++++++++--------------------- readme.txt | 1 + wp-strava.php | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/WPStrava/API.php b/lib/WPStrava/API.php index 0274eb1..cd912cb 100755 --- a/lib/WPStrava/API.php +++ b/lib/WPStrava/API.php @@ -18,6 +18,7 @@ class WPStrava_API { 'body' => http_build_query( $data ), 'sslverify' => false, 'headers' => array(), + 'timeout' => 30, ); if ( $this->access_token ) { diff --git a/lib/WPStrava/Settings.php b/lib/WPStrava/Settings.php index fe46f77..38c2c76 100644 --- a/lib/WPStrava/Settings.php +++ b/lib/WPStrava/Settings.php @@ -298,29 +298,19 @@ class WPStrava_Settings { $strava_info = $api->post( 'oauth/token', $data ); - if ( $strava_info ) { - if ( ! empty( $strava_info->access_token ) ) { - $this->feedback .= __( 'Successfully authenticated.', 'wp-strava' ); - return $strava_info->access_token; - } else { - if ( WP_STRAVA_DEBUG ) { - // Translators: message shown when there's an authentication problem with the Strava API (debug on). - $this->feedback .= sprintf( __( 'Authentication failed, OAuth response:
%s
', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output. - } else { - // Translators: message shown when there's an authentication problem with the Strava API. - $this->feedback .= __( 'Authentication failed, please check your credentials. See full error by adding
define( \'WP_STRAVA_DEBUG\', true );
to wp-config.php', 'wp-strava' ); - } - return false; - } - } else { - // Translators: error message from Strava - $this->feedback .= sprintf( __( 'There was an error receiving data from Strava: %s', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output. - return false; + if ( isset( $strava_info->access_token ) ) { + $this->feedback .= __( 'Successfully authenticated.', 'wp-strava' ); + return $strava_info->access_token; } - } else { - $this->feedback .= __( 'Missing Client ID or Client Secret.', 'wp-strava' ); + + // Translators: error message from Strava + $this->feedback .= sprintf( __( 'There was an error receiving data from Strava:
%s
', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output. return false; - } // End if. + + } + + $this->feedback .= __( 'Missing Client ID or Client Secret.', 'wp-strava' ); + return false; } public function print_gmaps_key_input() { diff --git a/readme.txt b/readme.txt index 9d48665..468615e 100755 --- a/readme.txt +++ b/readme.txt @@ -85,6 +85,7 @@ rawurlencode() redirect_uri so authentication works more consistently. Added FAQ about caching. Changed to new-style phpcs ignores and ignored some additional lines. Added debug option to Authentication Failed path for https://wordpress.org/support/topic/problem-authenticating-with-strava/ +Increased API Post timeout to 30 seconds. = 1.5.0 = diff --git a/wp-strava.php b/wp-strava.php index 826a4d3..4872253 100755 --- a/wp-strava.php +++ b/wp-strava.php @@ -3,7 +3,7 @@ * Plugin Name: WP Strava * Plugin URI: https://wordpress.org/plugins/wp-strava/ * Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license. - * Version: 1.5.1-rc2 + * Version: 1.5.1-rc3 * Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott * License: GPL2 * Text Domain: wp-strava