From 92fc229ca09cd4aa8ea5781f269a4efa8432f835 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 13 Jan 2020 17:25:26 +0000 Subject: [PATCH] Site Health: Avoid "Undefined property" PHP notices in `wp_dashboard_site_health()` when the status result transient does not exist yet. Props dlh for initial patch. See #47606. git-svn-id: https://develop.svn.wordpress.org/trunk@47069 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/dashboard.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 5a917f6b11..9533c24dec 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1772,21 +1772,21 @@ function dashboard_php_nag_class( $classes ) { function wp_dashboard_site_health() { $get_issues = get_transient( 'health-check-site-status-result' ); - $issue_counts = new stdClass(); + $issue_counts = array(); if ( false !== $get_issues ) { - $issue_counts = json_decode( $get_issues ); + $issue_counts = json_decode( $get_issues, true ); } - if ( ! is_object( $issue_counts ) || empty( $issue_counts ) ) { - $issue_counts = (object) array( + if ( ! is_array( $issue_counts ) || ! $issue_counts ) { + $issue_counts = array( 'good' => 0, 'recommended' => 0, 'critical' => 0, ); } - $issues_total = $issue_counts->recommended + $issue_counts->critical; + $issues_total = $issue_counts['recommended'] + $issue_counts['critical']; ?>
@@ -1821,7 +1821,7 @@ function wp_dashboard_site_health() {

- critical > 0 ) : ?> + 0 ) : ?>