Skip to content

Commit 9c88756

Browse files
haqadnmatticbot
authored andcommitted
Boost: Fix ISA showing an error if no report was found (#40660)
* Fix boost API client not properly parsing errors returned by wpcom * Fix showing error when a report wasn't found User might not have requested an analysis yet. That doesn't mean the UI should show an error. This restores behavior from pre-Boost 3.6.0. * Add changelogs * Revert boost core changes * remove changelog * Revert "Revert boost core changes" This reverts commit afa7179a61bdc347cb203233f9f4f33778ce2a29. * Revert "remove changelog" This reverts commit 870e13d0c0fd09966e3f36d1834bb9b5d67c6cff. * Clarify comment --------- Co-authored-by: Adnan Haque <[email protected]> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12438833474 Upstream-Ref: Automattic/jetpack@e564fe0
1 parent 0b6ffe3 commit 9c88756

File tree

11 files changed

+107
-81
lines changed

11 files changed

+107
-81
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ This is an alpha version! The changes listed here are not final.
2020
- Settings Page: Give Page Cache, Concatenate JS/CSS and Image CDN - Image Quality modules a more unifed look.
2121
- Updated package dependencies.
2222

23+
### Fixed
24+
- UI: Fixed showing an error if no ISA report was found.
25+
2326
## [3.6.1] - 2024-11-28
2427
### Changed
2528
- Image CDN: Improve performance. [#39883]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-date', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '3b96128358b1dfb105e9');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-date', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '19204e479cbd7b230d17');

app/assets/dist/jetpack-boost.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"automattic/jetpack-admin-ui": "^0.5.1",
1818
"automattic/jetpack-assets": "^4.0.2",
1919
"automattic/jetpack-autoloader": "^5.0.0",
20-
"automattic/jetpack-boost-core": "^0.3.2",
20+
"automattic/jetpack-boost-core": "^0.3.3-alpha",
2121
"automattic/jetpack-boost-speed-score": "^0.4.0",
2222
"automattic/jetpack-composer-plugin": "^4.0.0",
2323
"automattic/jetpack-config": "^3.0.0",

jetpack_vendor/automattic/jetpack-boost-core/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.3-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Fixed
13+
- General: Fixed not parsing error responses from WordPress.com properly.
14+
815
## [0.3.2] - 2024-11-28
916
### Fixed
1017
- Cachable: Make the expiry overridable by child classes. [#40339]
@@ -97,6 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
97104
### Added
98105
- Introduce new package. [#31163]
99106

107+
[0.3.3-alpha]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.2...v0.3.3-alpha
100108
[0.3.2]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.1...v0.3.2
101109
[0.3.1]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.0...v0.3.1
102110
[0.3.0]: https://github.com/Automattic/jetpack-boost-core/compare/v0.2.14...v0.3.0

jetpack_vendor/automattic/jetpack-boost-core/src/lib/class-utils.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,26 @@ public static function send_wpcom_request( $method, $endpoint, $args = null, $bo
133133
$code
134134
);
135135

136+
/*
137+
* Normalize error responses from WordPress.com.
138+
*
139+
* When WordPress.com returns an error from Boost Cloud, the body contains
140+
* statusCode and error. When it returns a WP_Error, it contains code and message.
141+
*/
136142
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
137-
$err_code = empty( $data['statusCode'] ) ? 'http_error' : $data['statusCode'];
138-
$message = empty( $data['error'] ) ? $default_message : $data['error'];
139-
140-
return new \WP_Error( $err_code, $message );
143+
if ( isset( $data['statusCode'] ) && isset( $data['error'] ) ) {
144+
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
145+
$data_code = $data['statusCode'];
146+
$data_message = $data['error'];
147+
} elseif ( isset( $data['code'] ) && isset( $data['message'] ) ) {
148+
$data_code = $data['code'];
149+
$data_message = $data['message'];
150+
}
151+
152+
$error_code = empty( $data_code ) ? 'http_error' : $data_code;
153+
$message = empty( $data_message ) ? $default_message : $data_message;
154+
155+
return new \WP_Error( $error_code, $message );
141156
}
142157

143158
return $data;

jetpack_vendor/automattic/jetpack-boost-speed-score/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"require": {
1717
"php": ">=7.2",
18-
"automattic/jetpack-boost-core": "^0.3.2"
18+
"automattic/jetpack-boost-core": "^0.3.3-alpha"
1919
},
2020
"autoload": {
2121
"classmap": [

jetpack_vendor/i18n-map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
),
1515
'jetpack-boost-core' => array(
1616
'path' => 'jetpack_vendor/automattic/jetpack-boost-core',
17-
'ver' => '0.3.2',
17+
'ver' => '0.3.3-alpha1734730585',
1818
),
1919
'jetpack-boost-speed-score' => array(
2020
'path' => 'jetpack_vendor/automattic/jetpack-boost-speed-score',

0 commit comments

Comments
 (0)