diff --git a/readme.txt b/readme.txt index 0b14aea..2683bee 100755 --- a/readme.txt +++ b/readme.txt @@ -138,6 +138,7 @@ On the WP-Strava settings page you cannot currently remove and add another athle Add ability to paste Activity/Route/Segment URL into the block editor and have it insert the appropriate block https://wordpress.org/support/topic/sorry-this-content-could-not-be-embedded-5/ Add `reduce_polyline()` for maps with large polylines but no summary provided (prevents empty map) https://wordpress.org/support/topic/map-embed-from-segment-shows-default-map/ Fix for ActivitiesList where lists were showing all zeroes https://wordpress.org/support/topic/zero-on-all-activities-for-club-on-list-mocule/ +Add additional authorization error logging to troubleshoot 401 Unauthorized https://wordpress.org/support/topic/wp-strava-error-401-unauthorized/ = 2.9.1 = diff --git a/src/WPStrava/AuthRefresh.php b/src/WPStrava/AuthRefresh.php index ba9bbbf..b7f0bd0 100644 --- a/src/WPStrava/AuthRefresh.php +++ b/src/WPStrava/AuthRefresh.php @@ -39,12 +39,23 @@ public function setup_auth_refresh_cron() { /** * Cron method to refresh auth tokens from Strava. * + * @throws WPStrava_Exception * @author Justin Foell * @since 2.0.0 */ public function auth_refresh() { $settings = WPStrava::get_instance()->settings; - foreach ( $settings->info as $client_id => $info ) { + $info = $settings->info; + + if ( ! is_array( $info ) ) { + $message = 'strava_info should be an array, received: ' . var_export( $info, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export -- Debug only. + if ( WPSTRAVA_DEBUG ) { + error_log( $message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Debug only. + } + throw new WPStrava_Exception( $message ); + } + + foreach ( $info as $client_id => $info ) { if ( ! empty( $info->refresh_token ) ) { $this->token_exchange_refresh( $client_id, $info ); }