warning: Invalid argument supplied for foreach()
florre - August 13, 2005 - 21:39
| Project: | Poormanscron |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi,
since installing the Google-sitemap-module and upgrading poormanscron-module to cvs I'm getting a few of the following warnings in the drupal log lately:
"Invalid argument supplied for foreach() in [...]/modules/poormanscron/poormanscron.module in Zeile 67."
Host is always GoogleBot (66.249.66.105), but it happens very irregularly.
The directory is /gsitemap, but it doesn't matter if the content of my site has changed or not...
Note sure if this is poormanscron's fault, or the sitemap-module...

#1
Hmmm ... maybe too complicated thinking ...
Don't get me wrong, it is a great module!
After the study of cron.php I took all 'message' related lines out and poormanscron-module is working fine since - better without the nasty error messages in the log file.
I'm watching the log carefully and I can't see any impact on other modules after my code change on poormanscron-module.
;-)
#2
Looks like a simple isset() check prior to rebuilding the messages helps (end of poormanscron_exit()). And it should be fine if you dont restore the messages if there arent any messages to begin with.
// Restore any prior messages.if(isset($saved_messages)) {
foreach ($saved_messages AS $type => $types_messages) {
foreach ($types_messages AS $message) {
drupal_set_message($message, $type);
}
}
}
I verfied this somewhat blind guess by changing the watchdog message to this:
watchdog('regular', 'Cron run completed ('.isset($saved_messages).').',WATCHDOG_NOTICE);
If the newsfeed is requested by some anonymous user the message is "Cron run completed()" otherwise its "Cron run completed(1)". So, yea... it might happen that the variable $saved_messages is NULL, which in turn causes that php error message.
HTH :)
#3
Fixed in HEAD and 4-6 (tarballs will be rebuilt in a few hours). Please reopen if there are problems.
#4
looks good :-)
#5