Site Health: Avoid a PHP notice in WP_Site_Health::wp_cron_scheduled_check() if async test response does not contain the expected result.

Additionally, avoid a PHP notice in `::get_test_php_version()` if the minimum recommended version of PHP could not be determined.

Props schlessera, oakesjosh.
Merges [47628] to the 5.4 branch.
Fixes #49943.
Built from https://develop.svn.wordpress.org/branches/5.4@47931


git-svn-id: http://core.svn.wordpress.org/branches/5.4@47704 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-09 11:27:09 +00:00
parent 5c256d1c7a
commit e23ccd2fcd

View File

@ -719,7 +719,7 @@ class WP_Site_Health {
sprintf(
/* translators: %s: The minimum recommended PHP version. */
__( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are faster and more secure, so staying up to date will help your site’s overall performance and security. The minimum recommended version of PHP is %s.' ),
$response['recommended_version']
$response ? $response['recommended_version'] : ''
)
),
'actions' => sprintf(
@ -2289,7 +2289,13 @@ class WP_Site_Health {
}
if ( ! is_wp_error( $result_fetch ) ) {
$results[] = json_decode( wp_remote_retrieve_body( $result_fetch ) );
$result = json_decode( wp_remote_retrieve_body( $result_fetch ), true );
} else {
$result = false;
}
if ( is_array( $result ) ) {
$results[] = $result;
} else {
$results[] = array(
'status' => 'recommended',