Opened 5 years ago
Closed 5 years ago
#49426 closed defect (bug) (fixed)
Site Health: the Rest API test doesn't display the WP_Error code
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.4 | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Site Health | Keywords: | has-screenshots has-patch commit |
Focuses: | ui | Cc: |
Description
When the Site Health "Rest API availability" test runs and returns a WP_Error
, it is supposed to display:
- the WP_Error code
- the WP_Error message
However, it fails to display the error code and shows just the error message. See in the screenshot below and notice there's nothing within the square brackets in the error details.
Turns out wp_remote_retrieve_response_code()
is used in the related code. However, when there's a WP_Error this function returns an empty string. In fact, it is designed to get HTTP errors code, while for the errors wrapped by WP_Error the related function get_error_message()
should be used instead.
Attachments (6)
Change History (13)
#2
@
5 years ago
- Keywords has-patch added
- Uses
get_error_message()
for the WP_Error case WP_Error
error codes aren't that useful for users, for example:bad_request
,http_request_failed
, etc.: moved the error code at the end of the string in a less prominent place- not sure why the
WP_Error
error code was displayed between square brackets while the HTTP error codes are displayed between parenthesis: standardized to parenthesis - tried to clarify the related translators comments
See the screenshot below with the error code now displayed at the end of the string.
This ticket was mentioned in Slack in #core-site-health by afercia. View the logs.
5 years ago
This ticket was mentioned in Slack in #core-site-health by afragen. View the logs.
5 years ago
#6
@
5 years ago
This looks good. But in my testing, I also noticed the same issue for the loopback test. 49426.2.diff fixes the issue there as well.
Quickest way to reproduce:
sleep( 10 );
to yourwp-config.php
filesrc
or thebuild
directory, in the former case you'll also need to build