PHP Warning: Invalid argument supplied for foreach() in /var/www/html/wp-cron.php
Lightning-fast WordPress on Nginx
Brought to you by:
jessuppi
Originally created by: corzel
Hello,
I see this warning in the error log file:
PHP Warning: Invalid argument supplied for foreach() in /var/www/html/wp-cron.php on line 117
Thank you!
Originally posted by: EdTrojas
Hello SS team
About the error: == PHP Warning: Invalid argument supplied for foreach () in /var/www/html/wp-cron.php==
I found a solution on a Wordpress forum. I´m not a developer, so I don't know if this solution has any harmful effect.
I am testing, monitoring, and waiting for some negative response when changing the WP-CRON.php code
-Is a wp bug, line 117 of wp-cron.php reads:
foreach ( $cronhooks as $hook => $keys ) {-this should read:
if ( $cronhooks ) foreach ( $cronhooks as $hook => $keys ) {or:
if ( is_array( $cronhooks ) ) foreach ( $cronhooks as $hook => $keys ) {-
this will prevent warning messages like: [Fri Aug 28 21:15:16.443167 2020] [fcgid:warn] [pid 62430] [client 77.68.64.25:32953] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /home/domains/vol3/578/2510578/user/htdocs/wp-cron.php on line 117, referer: https://www.pakohl.com/wp-cron.php?doing_wp_cron=1598645713.5858569145202636718750-when
$cronhooksisfalseThe solution was obtained by Jacob N. Breetvelt (@opajaap) in the following topic of the Wordpress.org support:
https://wordpress.org/support/topic/cron-errors-3/
Hope it works for you too.