Skip to content

Commit 8926f10

Browse files
committed
Explicitly autoload od_rest_api_unavailable option
1 parent 0693086 commit 8926f10

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

plugins/optimization-detective/site-health.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ function od_test_rest_api_availability(): array {
4646
$response = od_get_rest_api_health_check_response( false );
4747
$result = od_compose_site_health_result( $response );
4848
$is_unavailable = 'good' !== $result['status'];
49-
update_option( 'od_rest_api_unavailable', $is_unavailable ? '1' : '0' );
49+
update_option(
50+
'od_rest_api_unavailable',
51+
$is_unavailable ? '1' : '0',
52+
true // Intentionally autoloaded since used on every frontend request.
53+
);
5054
return $result;
5155
}
5256

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

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function test_rest_api_availability( $mocked_response, string $expected_o
157157
$this->assertArrayHasKey( 'description', $result );
158158
$this->assertArrayHasKey( 'test', $result );
159159
$this->assertSame( $expected_option, get_option( 'od_rest_api_unavailable', '' ) );
160+
$this->assertArrayHasKey( 'od_rest_api_unavailable', wp_load_alloptions(), 'Expected option to be autoloaded.' );
160161
$this->assertSame( $expected_status, $result['status'] );
161162
$this->assertSame( $expected_unavailable, od_is_rest_api_unavailable() );
162163
}

0 commit comments

Comments
 (0)