Skip to content

Commit c7a66ed

Browse files
marcinbotgithub-actions
andauthored
Fix address autocomplete token fetch logic (#61140)
* Fix address autocomplete token fetch logic * Add changefile(s) from automation for the following project(s): woocommerce * Fix lint * Fix lint --------- Co-authored-by: github-actions <[email protected]>
1 parent 396baf4 commit c7a66ed

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: update
3+
4+
Fix address autocomplete token fetch logic

plugins/woocommerce/src/Internal/AddressProvider/AbstractAutomatticAddressProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function can_telemetry() {
5555
* Loads up a JWT from cache or from the implementor side.
5656
*
5757
* @return void
58+
*
59+
* phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.Missing -- As we wrap the throw in a try/catch.
5860
*/
5961
public function load_jwt() {
6062

@@ -83,6 +85,8 @@ public function load_jwt() {
8385
// Clear retry data on success.
8486
$this->delete_cached_option( 'jwt_retry_data' );
8587
return;
88+
} else {
89+
throw new \Exception( 'Invalid JWT received from address service.' );
8690
}
8791
} catch ( \Exception $e ) {
8892
$retry_data['attempts'] = isset( $retry_data['attempts'] ) ? $retry_data['attempts'] + 1 : 1;
@@ -261,6 +265,10 @@ public static function get_asset_url( $path ) {
261265
* Enqueues the checkout script, checks if it's already registered or not so we don't duplicate, and prints out the JWT to the page to be consumed.
262266
*/
263267
public function load_scripts() {
268+
if ( ! is_checkout() ) {
269+
return;
270+
}
271+
264272
if ( ! $this->get_jwt() ) {
265273
return;
266274
}

0 commit comments

Comments
 (0)