#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
@
6 years ago
- Component General → Site Health
- Keywords needs-patch added
- Milestone Awaiting Review → 5.7
- Version → 5.2
This ticket was mentioned in PR #754 on WordPress/wordpress-develop by paulschreiber.
6 years ago
#3
- Keywords has-patch added; needs-patch removed
check if $core_updates is an array before iterating on it
Trac ticket: https://core.trac.wordpress.org/ticket/51818
Plugin issue: https://github.com/WordPress/health-check/issues/388
Plugin PR: https://github.com/WordPress/health-check/pull/390
hellofromtonya commented on PR #754:
6 years ago
#5
Trac ticket closed with changeset https://core.trac.wordpress.org/changeset/49676
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks for the report! Introduced in [44986] / #46573.
Yes, since
get_core_updates()returnsfalseon 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.