Skip to content

Commit 02953c7

Browse files
Change Site Health test from critical back to recommended
Co-authored-by: felixarntz <[email protected]>
1 parent b4736a4 commit 02953c7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

plugins/optimization-detective/site-health.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function od_compose_site_health_result( $response ): array {
110110
$error_description_html = '<p>' . esc_html__( 'You may have a plugin active or server configuration which restricts access to logged-in users. Unauthenticated access must be restored in order for Optimization Detective to work.', 'optimization-detective' ) . '</p>';
111111

112112
if ( is_wp_error( $response ) ) {
113-
$result['status'] = 'critical';
113+
$result['status'] = 'recommended';
114114
$result['label'] = $error_label;
115115
$result['description'] = $common_description_html . $error_description_html . '<p>' . wp_kses(
116116
sprintf(
@@ -134,8 +134,12 @@ function od_compose_site_health_result( $response ): array {
134134
count( $data['data']['params'] ) > 0
135135
);
136136
if ( ! $is_expected ) {
137-
$result['status'] = 'critical';
138-
$result['label'] = __( 'The Optimization Detective REST API endpoint is unavailable to logged-out users', 'optimization-detective' );
137+
$result['status'] = 'recommended';
138+
if ( 401 === $code ) {
139+
$result['label'] = __( 'The Optimization Detective REST API endpoint is unavailable to logged-out users', 'optimization-detective' );
140+
} else {
141+
$result['label'] = $error_label;
142+
}
139143
$result['description'] = $common_description_html . $error_description_html . '<p>' . wp_kses(
140144
sprintf(
141145
/* translators: %d is the HTTP status code, %s is the status header description */

plugins/optimization-detective/tests/test-site-health.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ public function data_provider_test_rest_api_availability(): array {
105105
'unauthorized' => array(
106106
'mocked_response' => $this->build_mock_response( ...self::UNAUTHORISED_MOCKED_RESPONSE_ARGS ),
107107
'expected_option' => '1',
108-
'expected_status' => 'critical',
108+
'expected_status' => 'recommended',
109109
'expected_unavailable' => true,
110110
),
111111
'forbidden' => array(
112112
'mocked_response' => $this->build_mock_response( ...self::FORBIDDEN_MOCKED_RESPONSE_ARGS ),
113113
'expected_option' => '1',
114-
'expected_status' => 'critical',
114+
'expected_status' => 'recommended',
115115
'expected_unavailable' => true,
116116
),
117117
'nginx_forbidden' => array(
@@ -123,13 +123,13 @@ public function data_provider_test_rest_api_availability(): array {
123123
'body' => "<html>\n<head><title>403 Forbidden</title></head>\n<body>\n<center><h1>403 Forbidden</h1></center>\n<hr><center>nginx</center>\n</body>\n</html>",
124124
),
125125
'expected_option' => '1',
126-
'expected_status' => 'critical',
126+
'expected_status' => 'recommended',
127127
'expected_unavailable' => true,
128128
),
129129
'error' => array(
130130
'mocked_response' => new WP_Error( 'bad', 'Something terrible has happened' ),
131131
'expected_option' => '1',
132-
'expected_status' => 'critical',
132+
'expected_status' => 'recommended',
133133
'expected_unavailable' => true,
134134
),
135135
);

0 commit comments

Comments
 (0)