#51818 closed defect (bug) (fixed)
Invalid value in foreach in debug_data()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Site Health | Keywords: | has-patch |
Focuses: | Cc: |
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.
3 years ago
#2
@
3 years ago
- Component changed from General to Site Health
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 5.7
- Version set to 5.2
This ticket was mentioned in PR #754 on WordPress/wordpress-develop by paulschreiber.
3 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
#4
@
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 49676:
hellofromtonya commented on PR #754:
2 years ago
#5
Trac ticket closed with changeset https://core.trac.wordpress.org/changeset/49676
Thanks for the report! Introduced in [44986] / #46573.
Yes, since
get_core_updates()
returnsfalse
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.