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.
Fixes #49943.

git-svn-id: https://develop.svn.wordpress.org/trunk@47628 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-04-27 21:59:10 +00:00
parent 86cbde382a
commit e46d1cfc84

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(
@ -2334,7 +2334,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',