WordPress.org

Make WordPress Core

Changeset 47069


Ignore:
Timestamp:
01/13/2020 05:25:26 PM (6 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/dashboard.php

    r47063 r47069  
    17731773    $get_issues = get_transient( 'health-check-site-status-result' );
    17741774
    1775     $issue_counts = new stdClass();
     1775    $issue_counts = array();
    17761776
    17771777    if ( false !== $get_issues ) {
    1778         $issue_counts = json_decode( $get_issues );
    1779     }
    1780 
    1781     if ( ! is_object( $issue_counts ) || empty( $issue_counts ) ) {
    1782         $issue_counts = (object) array(
     1778        $issue_counts = json_decode( $get_issues, true );
     1779    }
     1780
     1781    if ( ! is_array( $issue_counts ) || ! $issue_counts ) {
     1782        $issue_counts = array(
    17831783            'good'        => 0,
    17841784            'recommended' => 0,
     
    17871787    }
    17881788
    1789     $issues_total = $issue_counts->recommended + $issue_counts->critical;
     1789    $issues_total = $issue_counts['recommended'] + $issue_counts['critical'];
    17901790    ?>
    17911791    <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
     
    18221822    <?php else : ?>
    18231823        <p>
    1824             <?php if ( $issue_counts->critical > 0 ) : ?>
     1824            <?php if ( $issue_counts['critical'] > 0 ) : ?>
    18251825                <?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve the performance or security of your website.' ); ?>
    18261826            <?php elseif ( $issues_total <= 0 ) : ?>
Note: See TracChangeset for help on using the changeset viewer.