Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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!
Comment | File | Size | Author |
---|---|---|---|
#24 | 549042.patch | 640 bytes | haggins |
#10 | 0001-avoid-use-unintialized-data.patch | 9.31 KB | marvil07 |
#10 | realminorchange.patch | 1.8 KB | marvil07 |
#5 | drupal_calendar_issue.png | 72.76 KB | mxmilkiib |
Comments
Comment #1
mxmilkiib CreditAttribution: mxmilkiib commentedComment #2
mxmilkiib CreditAttribution: mxmilkiib commentedlooking 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.
Comment #3
arlinsandbulte CreditAttribution: arlinsandbulte commentedDid you run update.php?
Have your tried the latest module versions?
Comment #4
mxmilkiib CreditAttribution: mxmilkiib commentedyup, 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..
Comment #5
mxmilkiib CreditAttribution: mxmilkiib commentedComment #6
marcvangendI 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.
Comment #7
mxmilkiib CreditAttribution: mxmilkiib commentedfantastic, 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
Comment #8
mxmilkiib CreditAttribution: mxmilkiib commentedah, 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)
Comment #9
marcvangendMaybe 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.
Comment #10
marvil07 CreditAttribution: marvil07 commentedI 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
Comment #11
StephenRobinson CreditAttribution: StephenRobinson commentedThanks, this has been driving me me nuts all day, calendar-day.tpl.php was being called twice, once with empty data, throwing 2 foreach errors.
* warning: Invalid argument supplied for foreach() in /home/%/sites/all/modules/calendar/theme/theme.inc on line 296.
* warning: Invalid argument supplied for foreach() in /home/%/sites/all/modules/calendar/theme/theme.inc on line 321.
S:)
Comment #12
bjordan CreditAttribution: bjordan commentedComment #6 by marcvangend helped fix my issue, make sure to use the Calendar Navigation style for the Page view
Comment #13
renenee CreditAttribution: renenee commentedI have the same exact issue mentioned in the initial post; however, I looked into Comment #6, and my views were setup already the way described in 6.x-2.2 (view style "calendar navigation" for my block view and view style "calendar" for my week view attachment). Is anyone else encountering this? Has anyone else found a solution?
Comment #14
alexkb CreditAttribution: alexkb commentedJust to add, if it's not clear, solution proposed in comment #6 will solve the issue in comment #11. Thanks!
Comment #15
jim.phelan CreditAttribution: jim.phelan commented#14, rmd-14, I had the same problem, although, like you, my Calendar Pages style was set to 'calendar navigation'. I had added an additional custom attachment which had its style set to 'Calendar' - just like Day, Week, Month. However the data it contained was from a different content type (created by 'Date Wizard'). When I changed the style for this new attachment to 'Unformatted' the error went away.
Comment #16
haggins CreditAttribution: haggins commentedI'm getting warning: "Invalid argument supplied for foreach() in /mypath/sites/all/modules/calendar/theme/theme.inc on line 425.", too. It only appears on week-view for the first 9 weeks of the year.
How to reproduce:
1. Use latest version of date, calendar, views 2.x
2. Set first day of week to 'monday'
3. Enable "Use ISO-8601 week numbers" (no error with this function disabled!)
4. display one of the first nine weeks "calendar/2010-W[01-09]"
I figured out that the $vars parameter of template_preprocess_calender_week() contains wrong formatted rows. Look at the following example when visiting week 01:
dpr($vars['rows']) prints:
Second key should be named "1". If you visit week 08, second key is named "08". However it should always be named "1".
Does anyone else experience this bug, too?
I also tried to figure out where $vars is created - without success. Result of calendar_build_week() seems to be alright.
Since many people will have problems at the beginning of 2011 I will mark this issue as critical.
Comment #17
haggins CreditAttribution: haggins commentedComment #18
marvil07 CreditAttribution: marvil07 commentedMoving to normal as it not seems like a general problem(mainly something related with specific data, see priority).
Moving to the rigth status again.
Comment #19
hs@henrikstrindberg.se CreditAttribution: hs@henrikstrindberg.se commentedIt's the one digit weeks 1-9 any year and only in week-view . Yes I have the save problem.
Comment #20
seanBWe have the same problem as #16. Week number 1 - 9 of every year gives errors:
Invalid argument supplied for foreach() in /calendar/theme/theme.inc on line 425
The template function template_preprocess_calendar_week() is only called once, so this is not the same problem as marcvangend had in #6. In about 4 weeks we are in week 1 already, so this problem is about to become pretty critical to me as well..
Comment #21
KoCo CreditAttribution: KoCo commented+1
Same problem as #16 describes. When I switch it all off, week links need two digits.
Week links should be investigated again =(.
Comment #22
haggins CreditAttribution: haggins commentedWe should mark this as "active" since there is nothing to review.
Comment #23
seanBJust found out what the problem is!
- In line 404 of calendar/theme/theme.inc there is a call to template_preprocess_calendar($vars);
- It uses calendar_build_calendar() to build the $rows var
- In calendar_build_week() of includes/calendar.inc there's a call to date_week() of the dateapi on line 87. This is to get the week number based on the current date.
- The date_week function returns the week number, but for weeks 1 - 9, the week number is returned as 01, 02, 03 etc. wich results in the variable being treated as a string
- In the array_merge on line 52 of includes/calendar.inc this causes the array not to be renumbered.
The proper way to fix this I guess is to make sure the date_week() function of the Date API returns integers. If you change line 86 of includes/calendar.inc to the following this will work too:
$week = intval(date_week($curday_date));
Comment #24
haggins CreditAttribution: haggins commentedGreat! This fixed the issue for me. Thanks, sweetBricks!
Here it is as patchfile:
Comment #25
marcvangendGood catch, sweetBricks.
This is micro-optimization, not tested, but I think we can just cast to int instead of using the intval() function which has slightly more overhead on the php level:
$week = (int)date_week($curday_date);
.Comment #26
clintthayer CreditAttribution: clintthayer commentedSubscribe
Comment #27
crutch CreditAttribution: crutch commented#24 fixed for me, subscribe
Comment #28
dhendriks CreditAttribution: dhendriks commented#24 fixed it for me as well. subscribing...
Comment #29
KarenS CreditAttribution: KarenS commentedGood detective work, but a better fix is to fix the date_week() function, which should be returning an integer, to ensure that anything else that expects a numeric week gets one.
Thanks!