The following errors appear at the top of the calendar-date/week page:

Notice: Undefined index: groupby_times in template_preprocess_calendar_week() (line 477 of C:\mowes_portable\www\drupal\sites\all\modules\calendar\theme\theme.inc).
Notice: Undefined variable: divisor in template_preprocess_calendar_week() (line 490 of C:\mowes_portable\www\drupal\sites\all\modules\calendar\theme\theme.inc).
Warning: Division by zero in template_preprocess_calendar_week() (line 490 of C:\mowes_portable\www\drupal\sites\all\modules\calendar\theme\theme.inc).
Notice: Undefined variable: divisor in template_preprocess_calendar_week() (line 491 of C:\mowes_portable\www\drupal\sites\all\modules\calendar\theme\theme.inc).
Warning: Division by zero in template_preprocess_calendar_week() (line 491 of C:\mowes_portable\www\drupal\sites\all\modules\calendar\theme\theme.inc).

Calendar week view displays normally below these errors.
Errors disappear when there are no events in the week.

Calendar was working fine prior to updating to new 7.x-3.0-alpha2 version. Have now upgraded to 7.x-3.x-dev version, but errors still there.
Have also updated to latest -dev version of Date module.
Have followed these debugging steps: http://drupal.org/node/755312
Drupal version 7.9
Many thanks

Files: 

Comments

Version:7.x-3.x-dev» 7.x-3.0-alpha2

Same errors with alpha 2 release + week view.

Status:Active» Postponed (maintainer needs more info)

try the most recent -dev.

Version:7.x-3.0-alpha2» 7.x-3.x-dev
Status:Postponed (maintainer needs more info)» Active

I just updated to the most recent -dev for Date. I already have the -dev for Calendar.
Still getting errors.
I have also upgraded to Drupal 7.10

Has anyone solved this yet? I am getting the same errors. It has been driving me crazy.

sub

I'm getting this error as well on a fresh install as of today.
If I have an all day event or an event with no specified end time(which then shows up as an all day event) it works fine with no errors.

I am getting this exact error on the week view under the exact same conditions:
Calendar 7.x-3.x-dev
Date 7.x-2.0-rc1+69-dev

I got the error first when upgrading to:
Calendar 7.x-3.0-alpha2
Date 7.x-2.0-rc1

Then I moved to the dev version of both modules as I understood those were recommended at this time.

I experimentally backed out changes via git, and I believe this is the commit that introduced the problem:

commit c91e0a69904bf8070136e31037a2db88083c4a34
Author: Karen Stevenson <karen@elderweb.com>
Date:   Fri Dec 30 05:42:40 2011 -0600
    Issue #1305938 by kristiaanvandeneynde and KarenS, Make sure the overlapping items work correc...

The error occurs when a date field during the week shown has an end date. If there is no end date for any event, no error is shown. In addition, even events without end dates are incorrectly shown in the all-day portion of the days. (EDIT: oops, #6 already noted this).

The only notice to pay attention to here is the first one.
The other four notices are a direct consequence of the first.

<?php
// The whole issue lies within the fact that the view doesn't
// have the style option "groupby_times". This is not necessarily
// an issue with the patch in #1305938, as that patch had nothing
// to do with how Calendar adds style options to a view.
/*477*/
switch ($view->style_options['groupby_times']) {
/*478*/   case 'half':
/*479*/     $group_time = 30;
/*480*/     $divisor = 7.5;
/*481*/     break;
/*482*/   case 'hour':
/*483*/     $group_time = 60;
/*484*/     $divisor = 15;
/*485*/     break;
/*486*/   default:
/*487*/     continue;
/*488*/ }
?>

Find out why the style option groupby_times is missing and this issue is resolved.

For convenience, here's the diff showing the changes.

There is some slightly odd code near the error. Notice how $display_overlap gets tested redundantly:

473     if ($display_overlap) {
474        foreach ($grouped_items[$start_time]['values'] as $wday => &$items) {
475          foreach ($items as &$item) {
476            if ($display_overlap) {
477              switch ($view->style_options['groupby_times']) {

OK, this is apparently due to an uninitialized value in the Calendar View.
Here's how to fix an existing view:

  1. Go to your Calendar View.
  2. Choose the Week Display.
  3. Click on Settings in Format: Calendar | Settings .
  4. You'll see Time Grouping, with the dropdown set to Hour.
  5. You don't need to change anything, but click Apply (this display).
  6. Then don't forget to click Save on the View editing page.
  7. Now go to the Week view for your calendar. The error should be gone.

Why there's an uninitialized value I don't know and needs further research, but the above should remove the error from an existing view.

I was just able to fix it by editing the view for week view, then clicking on settings under FORMAT.
I made sure the group by was set to hour and then applied the new settings and now it works with no errors.
Now that it's working even if I go back in and set the group by to none it still displays without errors.
So maybe when the default calendar views are created the code that is supposed to set the default group by times isn't working.

Edit*
it looks like Dan posted a more detailed description while I was typing this out.

StatusFileSize
new815 bytes

Here is a one-line patch to fix the uninitialized value in the creation of the default view. Any existing views will have to be fixed by the steps in #11, though, I think.

This is my first patch and I'm not sure whether there are other things necessary to do to force the default view to be regenerated on a module update.

Status:Active» Needs review

to auto-test patch

Patch seems pretty simple and okay to me to be honest.
(Not tested though)

#11 - dhalbert's solution worked perfectly for me. No patch needed. Thanks!

I do think a patch is needed to prevent others from getting this error in the future.

This problem actually exposed (or is exposed by) another problem, I suggest looking at: #1433046.

I created that issue as a separate issue because I think this one only addresses whether or not groupby_times is defined while that issue addresses a PHP coding problem.

Status:Needs review» Fixed

I'm committing this, but I'm working on a new view -- using templates instead of the default view. There will be a template for every date field that you can use to start a calendar and the default view will go away.

http://drupalcode.org/project/calendar.git/commit/4a29479

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

I have just tried installing the latest dev of the calendar and it breaks my drupal 7
i.e. blank screen and the following message in the httpd error log:
PHP Fatal error: Call to undefined function date_views_base_tables() in /var/www/html/aps7/sites/all/modules/calendar/includes/calendar.views.inc on line 18

Do I need the dev version of views too?

Sorry I now realize that I needed to get the dev version od date which I have done but I still get these errors:
Notice: Undefined index: groupby_times in template_preprocess_calendar_week() (line 478 of .../modules/calendar/theme/theme.inc).
Notice: Undefined index: groupby_times in template_preprocess_calendar_week() (line 482 of .../modules/calendar/theme/theme.inc).

Did you read and try #11?

OK
Now that I read it all more closely including #11 my problem is gone.
Sorry for this clutter.
Congratulations on the improvements in calendar/date etc.
It is quite nice now!

Bill

Thanks dhalbert,

I just did drush up to d7.12 and calender 7.x-3.0 and then used your solution on #11. Everything worked fine.

I am currently running:
Drupal core 7.12, Calendar 7.x-3.0+7-dev (2012-Mar-25) etc.

I just encountered this same problem so I applied the fix in #11 and now everything works fine.

Thanks to Dan for identifying the problem...I was just about to start deleting views and then rebuilding them :o

Hopefully the fix will get committed soon.

Cheers

In my setup the groupby_times is not exported to the views code when using features. Anyone else experiencing this?

To clarify - the problem is not features. The groupby_times value is not exported through views export.
If I change the field to something else, it seems to be exported correct.
Perhaps this is just an error in my setup.

great, @dhalbert! many thx for solution in #11. instantly solved my problem!
karl

Yes I am having the same export problem.

I can fix the proble with commit #11, but the export before 11 and after 11 are exactly the same. When exported directly from the views interface. (not even using features)

Yes!! it works for me but why is this type of issue ?

#11 worked for me.

#11 also worked for me.. and the problem was not only in the week view, but in the day view also. Both solved thanks.

#11 worked for me!!

#11 woks either for Week end Day in view

Is #11 mentioned in the readme file? Might be worth putting some documentation to this if not.

Many thanks dhalbert for your solution.

I have posted a summary of this problem that has been noted several times in the issue queue. I have also posted a patch. See #2160183: Undefined index: groupby_times - FIX

Thanks eft, not seen that post. It's only got 1 follower so I don't think others have either.

@kingfisher64 - If you can review the patch, that would be great.