Skip to content

Commit

Permalink
Remove overkill type checking for transient response
Browse files Browse the repository at this point in the history
Co-authored-by: felixarntz <[email protected]>
  • Loading branch information
westonruter and felixarntz committed Jan 17, 2025
1 parent ddc6164 commit b4736a4
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions plugins/optimization-detective/site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,8 @@ function od_compose_site_health_result( $response ): array {
*/
function od_get_rest_api_health_check_response( bool $use_cached ) {
$transient_key = 'od_rest_api_health_check_response';
$response = $use_cached ? get_transient( $transient_key ) : null;
if (
(
is_array( $response )
&&
isset( $response['response']['code'], $response['response']['message'], $response['body'] )
&&
is_int( $response['response']['code'] )
&&
is_string( $response['response']['message'] )
&&
is_string( $response['body'] )
)
||
is_wp_error( $response )
) {
$response = $use_cached ? get_transient( $transient_key ) : false;
if ( false !== $response ) {
return $response;
}
$rest_url = get_rest_url( null, OD_REST_API_NAMESPACE . OD_URL_METRICS_ROUTE );
Expand Down

0 comments on commit b4736a4

Please sign in to comment.