Skip to content

Commit

Permalink
Boost: Fix ISA showing an error if no report was found (#40660)
Browse files Browse the repository at this point in the history
* 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 <adnan007.id@gmail.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12438833474

Upstream-Ref: Automattic/jetpack@e564fe0
  • Loading branch information
haqadn authored and matticbot committed Dec 20, 2024
1 parent 0b6ffe3 commit 9c88756
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 81 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ This is an alpha version! The changes listed here are not final.
- Settings Page: Give Page Cache, Concatenate JS/CSS and Image CDN - Image Quality modules a more unifed look.
- Updated package dependencies.

### Fixed
- UI: Fixed showing an error if no ISA report was found.

## [3.6.1] - 2024-11-28
### Changed
- Image CDN: Improve performance. [#39883]
Expand Down
2 changes: 1 addition & 1 deletion app/assets/dist/jetpack-boost.asset.php
Original file line number Diff line number Diff line change
@@ -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');
<?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');
2 changes: 1 addition & 1 deletion app/assets/dist/jetpack-boost.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"automattic/jetpack-admin-ui": "^0.5.1",
"automattic/jetpack-assets": "^4.0.2",
"automattic/jetpack-autoloader": "^5.0.0",
"automattic/jetpack-boost-core": "^0.3.2",
"automattic/jetpack-boost-core": "^0.3.3-alpha",
"automattic/jetpack-boost-speed-score": "^0.4.0",
"automattic/jetpack-composer-plugin": "^4.0.0",
"automattic/jetpack-config": "^3.0.0",
Expand Down
8 changes: 8 additions & 0 deletions jetpack_vendor/automattic/jetpack-boost-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.3-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Fixed
- General: Fixed not parsing error responses from WordPress.com properly.

## [0.3.2] - 2024-11-28
### Fixed
- Cachable: Make the expiry overridable by child classes. [#40339]
Expand Down Expand Up @@ -97,6 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Introduce new package. [#31163]

[0.3.3-alpha]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.2...v0.3.3-alpha
[0.3.2]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/Automattic/jetpack-boost-core/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/Automattic/jetpack-boost-core/compare/v0.2.14...v0.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,26 @@ public static function send_wpcom_request( $method, $endpoint, $args = null, $bo
$code
);

/*
* Normalize error responses from WordPress.com.
*
* When WordPress.com returns an error from Boost Cloud, the body contains
* statusCode and error. When it returns a WP_Error, it contains code and message.
*/
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$err_code = empty( $data['statusCode'] ) ? 'http_error' : $data['statusCode'];
$message = empty( $data['error'] ) ? $default_message : $data['error'];

return new \WP_Error( $err_code, $message );
if ( isset( $data['statusCode'] ) && isset( $data['error'] ) ) {
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$data_code = $data['statusCode'];
$data_message = $data['error'];
} elseif ( isset( $data['code'] ) && isset( $data['message'] ) ) {
$data_code = $data['code'];
$data_message = $data['message'];
}

$error_code = empty( $data_code ) ? 'http_error' : $data_code;
$message = empty( $data_message ) ? $default_message : $data_message;

return new \WP_Error( $error_code, $message );
}

return $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"require": {
"php": ">=7.2",
"automattic/jetpack-boost-core": "^0.3.2"
"automattic/jetpack-boost-core": "^0.3.3-alpha"
},
"autoload": {
"classmap": [
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
),
'jetpack-boost-core' => array(
'path' => 'jetpack_vendor/automattic/jetpack-boost-core',
'ver' => '0.3.2',
'ver' => '0.3.3-alpha1734730585',
),
'jetpack-boost-speed-score' => array(
'path' => 'jetpack_vendor/automattic/jetpack-boost-speed-score',
Expand Down
Loading

0 comments on commit 9c88756

Please sign in to comment.