From 556ee6cd188ccdcf19e4af00d898d8fac41f8234 Mon Sep 17 00:00:00 2001 From: "Marius L. J" Date: Thu, 20 May 2021 11:08:15 +0000 Subject: [PATCH] Site Health: Skip REST tests during scheduled events. This change fixes a false positive that would appear during scheduled events, by only running the REST test when a user visits the Site Health page, meaning an active session is available. The test checking if the REST API is available, includes a parameter for `context=edit` to make sure the block editor can function properly. This means a user session with editor capabilities is required for the test to pass, which is not the case during a scheduled event. Props szaqal21, TimothyBlynJacobs, hermpheus. Fixes #52112. git-svn-id: https://develop.svn.wordpress.org/trunk@50939 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-site-health.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index a21045d291..be1d439aee 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -2361,8 +2361,9 @@ class WP_Site_Health { // Conditionally include REST rules if the function for it exists. if ( function_exists( 'rest_url' ) ) { $tests['direct']['rest_availability'] = array( - 'label' => __( 'REST API availability' ), - 'test' => 'rest_availability', + 'label' => __( 'REST API availability' ), + 'test' => 'rest_availability', + 'skip_cron' => true, ); } @@ -2729,6 +2730,9 @@ class WP_Site_Health { } foreach ( $tests['direct'] as $test ) { + if ( ! empty( $test['skip_cron'] ) ) { + continue; + } if ( is_string( $test['test'] ) ) { $test_function = sprintf(