0

Suddenly, my php log is getting flooded with this php warning:

Got error 'PHP message: PHP Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-dashboard.php on line 543', referer:

The warning always keep the same but the referer could be literally any page of the site, including back and front end. I really don't have a clue whats going on.

Any ideas?

JBassino
  • 1
  • 1
  • Version of PHP, Wordpress and Woocommerce? – Cristino Nov 16 '21 at 02:22
  • Everything is up to the latest version. Wordpress 5.8.2 WooCommerce 5.9.0 PHP 7.4 – JBassino Nov 16 '21 at 15:19
  • Please provide enough code so others can better understand or reproduce the problem. – Gary Houbre Nov 17 '21 at 11:59
  • `foreach ( $data as $d ) { $total += $d['subtotals']->$meta_key; array_push( $sparkline_data, array( strval( strtotime( $d['interval'] ) * 1000 ), $d['subtotals']->$meta_key ) ); }` This is the line of code the warning is refering to – JBassino Nov 17 '21 at 13:45

1 Answers1

1

Using a solution found in Invalid argument supplied for foreach()

You can edit 'class-wc-admin-dashboard.php' and add this code in line 543 (just before the foreach):

if (is_array($data) || is_object($data))
corzel
  • 11
  • 1