Invalid argument supplied for foreach() ... etc
milkmiruku - August 14, 2009 - 08:14
| Project: | Calendar |
| Version: | 6.x-2.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | warning |
Description
I'm getting;
* warning: Invalid argument supplied for foreach() in /home/forest/public_html/modules/calendar/theme/theme.inc on line 425.
* warning: Invalid argument supplied for foreach() in /home/forest/public_html/modules/calendar/theme/calendar-week.tpl.php on line 49.
when accessing a weekly view - http://theforest.org.uk/events/2009-W31
or a daily view - http://theforest.org.uk/events/2009-08-22
though the monthly calendar seems to be working fine.
Any thoughts or suggestions? Thanks!

#1
#2
looking at this again;
i don't know if it's any help, but i've noticed that the date title plus 'Prev' and 'Next' links are not there.
also, on the day view, the Items column is showing twice.
does 2.x-dev use the same db schema as 2.2? if so i could try moving back to that to see if there's any difference.
#3
Did you run update.php?
Have your tried the latest module versions?
#4
yup, update.php is always run when upgrading.
have been using the latest dev calendar and i've just upped to 6.14 and the latest dev version of date, no change in the issue. as above, the Prev and Next links are missing on all calendar views.
'Events' is a panel page, but the calendar page view with all the same symptoms can be seen @ http://theforest.org.uk/eventcalendar
i attach an image with the Default, Calendar page and Month view in case any of these might shed some light on the issue..
#5
#6
I had the same errors since I updated to Calendar 6.x-2.2. A closer look revealed that function template_preprocess_calendar_week() was called twice: once for the Week view attachment, once for Calendar page. The second call caused the error, because the view style was still set to 'calendar' which is not a valid option for the Calendar page. Settings the Calendar page's view style to 'Calendar navigation' fixed the issue for me. Milkmiruku, your screenshots look as if your situation is identical.
#7
fantastic, thanks! this fixed the calendar page - http://theforest.org.uk/eventcalendar - and the calendar block also.
problem being that now the calendar view has broken - http://theforest.org.uk/events
i've not got the time to fix now but i'll post with developments for others with the same issue once i've had a crack at the settings
#8
ah, i just needed to remove and readd the calendar view in the panel, selecting 'Calendar page' at this point (which you can't change from the settings in an existing panel view item config after it has been created, which is kinda unuser friendly, but hey)
#9
Maybe it's good to mention that when you fix the problem in the way I described, you have to be careful that you ONLY change the Calendar page's view style (click override if necessary). If you would update the view's default style to Calendar navigation, that might break another display.
#10
I could not resolve this with the solution proposed.
This is my first time trying to modify this module, so sorry if I'm not resolving this in the right way.
But here is a little patch
0001-avoid-use-unintialized-data.patch, that mainly validate data before use it; the other lines are only indentation stuff, so if you want to see only the real line changes seerealminorchange.patch