[wp-trac] [WordPress Trac] #51818: Invalid value in foreach in debug_data()

WordPress Trac noreply at wordpress.org
Wed Nov 18 17:01:05 UTC 2020


#51818: Invalid value in foreach in debug_data()
---------------------------+-----------------------------
 Reporter:  paulschreiber  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 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
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51818>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list