Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#51818 closed defect (bug) (fixed)

Invalid value in foreach in debug_data()

Reported by: paulschreiber Owned by: SergeyBiryukov
Priority: normal Milestone: 5.7
Component: Site Health Version: 5.2
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Also filed as ​https://github.com/WordPress/health-check/issues/388

### Feature request/bug description

I'm seeing this warning:

Warning: Invalid argument supplied for foreach() in /home/customer/www/empirejustice.org/public_html/
wp-content/plugins/health-check/includes/class-health-check-debug-data.php on line 59

related code:

<?php
  59                 foreach ( $core_updates as $core => $update ) {
  60                         if ( 'upgrade' === $update->response ) {
  61                                 // translators: %s: Latest WordPress version number.
  62                                 $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)', 'health-chec     k' ), $update->version );
  63                         } else {
  64                                 $core_update_needed = '';
  65                         }
  66                 }

Debugging, I see $core_updates is false. I suspect this is because of Siteground's own updater.

Adding an if ( is_array( $core_updates ) ) { check avoids the problem.

Change History (5)

This ticket was mentioned in ​Slack in #core-site-health by paulschreiber. ​View the logs.


6 years ago

#2 @SergeyBiryukov
6 years ago

  • Component General → Site Health
  • Keywords needs-patch added
  • Milestone Awaiting Review → 5.7
  • Version → 5.2

Thanks for the report! Introduced in [44986] / #46573.

Yes, since get_core_updates() returns false on failure, it makes sense to account for that value as well.

Moving to 5.7, as 5.6 is already in RC stage, and this does not appear to be a recent regression.

This ticket was mentioned in ​PR #754 on ​WordPress/wordpress-develop by ​paulschreiber.


6 years ago
#3

  • Keywords has-patch added; needs-patch removed

#4 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 49676:

Site Health: Check if $core_updates is an array before iterating on it.

This avoids a PHP warning if get_core_updates() returns false.

Props paulschreiber.
Fixes #51818.

​hellofromtonya commented on ​PR #754:


6 years ago
#5

Trac ticket closed with changeset https://core.trac.wordpress.org/changeset/49676

Note: See TracTickets for help on using tickets.