Since upgrading to the latest Date, Calendar and Views my iCal feed seems to only be displaying events which have no repeating data and only exist on a single day. Other than that, the scope of the feed seems to be correct. I don't know what other information I can provide, so please let me know if there's more I can do.

I'm using php5 and the latest dev version of Date.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FoolsRun’s picture

Project: Date » Calendar
Component: iCal API » iCal export

Moved to "Calendar" module, since it's probably more closely related to that.

The SQL queries shown for "Month View" and "iCal Feed" appear identical, but Month View shows repeating events and iCal Feed doesn't.

Events shown are events that exist only on a single day during the current month. Anything that starts before this month and repeats into or through this month is not shown.

FoolsRun’s picture

There appear to be a few forces at work here, one, the query for the iCal feed seems to be confined to the current month, I thought this had been changed in a previous version to show a pre-set number of days ahead of "now". In addition to that, the query doesn't seem to be interpreting RRULES for events which started before "now" and which repeat into the future. On my calendar, most events are weekly or monthly repetitions starting whenever the user submitted them and repeating pretty much indefinitely.

Please let me know what other information I can provide to help narrow down this problem.

FoolsRun’s picture

Title: iCal Feed only showing non-repeating events » iCal Feed Not Showing Repeating Events Which Start Before The View Window

Just updating with a little more info;
I reverted and rebuilt my Calendar views today to see if this issue was merely due to my tinkering --it was not, the problem seems to appear on a clean copy of Calendar.

To re-create the problem:

Create an event which repeats weekly, starting at some point before the granularity of the "Argument" date (any date in 2008 would work). Also create an event which takes place tomorrow and does not repeat.

Set iCal Feed view filters to show:
Node: Published Yes
Date: Date Content: Date and Time (field_date) - From date >= now

Now view or preview the iCal output, note that the repeating event does not appear in the output.

For extra interesting points, if I set the "Items to display" to "10" (from "unlimited"), no events show in my output, leading me to think it's counting the repeating events but not putting them in the feed for some reason.

EDIT: the "Upcoming" and "Month View" views show all the repeating dates properly, the problem only appears in the iCal view.

FoolsRun’s picture

This is still a problem in the latest -dev versions of date/calendar. Examples of the types of events which could be affected by this bug are birthdays, anniversaries, monthly events that repeat for several months in a row, etc.

FoolsRun’s picture

It probably doesn't matter since this issue doesn't seem to interest the devs but I think I've isolated some code related to this problem:
In calendar.inc around line 371:

  if (strstr($view->current_display, '_ical') && !empty($rrule_field) && !empty($item->$rrule_field)) {
        if (!in_array($rrule_field, $rrule_processed)) {
          $rrule_processed[] = $rrule_field;
        }
        else {
          continue;
        }
      }

Commenting out these lines fixes the problem. My iCal export shows every event with repeats in the exported period (each as an individual VEVENT in the .ics exported file, unfortunately) including those that start and end before or after that period.

Obviously commenting this out is not ideal but it seems that this piece of code isn't behaving the way it should --it seems that events with rrules are being dropped entirely rather than, as this code seems intended, to appear once and letting the rrule do the rest of the work.

I'd love to know if this could even be confirmed or denied by the developers. Even just "Yes, it seems to be a bug, but we're not focused on that right now" would be nice.

bwynants’s picture

This helped me out....

Thanks

bwynants’s picture

Seems like this was a combination of problems....

see http://drupal.org/node/424048

and change the lines into (notice the added node id to the rrule_processed strings....)

I have 2 nodes with a similar repeating field and I saw only one of the repeating events

      // When creating iCal feeds for repeating dates we don't want all
      // the multiple values, send only the first value.
      if (strstr($view->current_display, '_ical') && !empty($rrule_field) && !empty($item->$rrule_field)) {
        if (!in_array($rrule_field + ':' + $item->nid, $rrule_processed)) {
          $rrule_processed[] = $rrule_field + ':' + $item->nid;
        }
        else {
          continue;
        }
      }
bwynants’s picture

Status: Active » Needs review
FileSize
2.15 KB

patch attached

michaelchoffman’s picture

After applying the attached patch file I still receive the error in google.
When adding the feed in google http:///calendar/ical
I get the error:
Settings Error
We could not parse the calendar at the url requested.

Example calendar.ics file:
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=2TH;UNTIL=20140927T131414Z;COUNT=52;WKST=SU

So it looks like the patch made the changes noted in this thread, however, it seems google still does not accept it.

Any help would be greatly appreciated as everything else works.
On as side note, it seems that Gnome Evolution Calendaring system accepts both formats of the ical as it displays the events just fine.

bwynants’s picture

I'm using this for a while with google with no problems.

can you download the created ics file and attach it here?

mxmilkiib’s picture

subscribe

Gribnif’s picture

FileSize
1.66 KB

I just spent some time tracking down this same bug. I now wish I had searched first.

Anyway, I believe the original intent was to have been this:

      if (strstr($view->current_display, '_ical') && !empty($rrule_field) && !empty($item->$rrule_field)) {
        if (!in_array($item->$rrule_field, $rrule_processed)) {
          $rrule_processed[] = $item->$rrule_field;
        }
        else {
          continue;
        }
      }

Note the addition of "$item->" to both the "if" and what is being stored in the array. However, IMHO, even this isn't sufficient, since there's still the possibility of two events having overlapping repeat rules which cause a false positive. The patch by @bwynants does address this problem, but isn't as efficient as it could be. I propose this version, instead:

      if (strstr($view->current_display, '_ical')) {
        if (!isset($rrule_processed[$item->nid])) {
          $rrule_processed[$item->nid] = TRUE;
        }
        else {
          continue;
        }
      }

It's much faster to use isset() than in_array() for this sort of thing, and the only unique thing about the rule that is needed is the nid. The $rrule_field is constant for all $items, so there's no sense storing it.

Attached is a patch which does this.

Gribnif’s picture

I also see this topic, which covers this same issue in a different way: #446614: iCal empty

bwynants’s picture

Andrew Howlett’s picture

First thank you to all the drupal devs and testers. I am a volunteer webmaster for a not for profit (http://bruceskiclub.ca). Drupal has worked very well for us.

I have problems with ical which might be related to this thread. I think it is an interesting problem, but I hope you don't mind reading all the background info first.

I created my calendar using the exact procedure shown at http://www.drupaltherapy.com/date. I have entered ten dates in my calendar (in calendar order, not order of creation):

2009-10-05 Ski Testing and Grinding
2009-10-15 Executive Meeting
2009-10-18 Sawmill Trail Work Party
2009-10-18 SOD AGM
2009-10-24 Rankin Trail Work Party
2009-11-07 Ski Swap at Suntrail
2009-11-15 Early Bird Registration Deadline
2010-01-23 Ski Exchange with Sauble Ski Club
2010-02-07 Suntrail Special Race
2010-02-13 Winterama

The ical view settings are default (argument: date node; fields: content date (from date)) except that I have set a filter for all dates between 1 Sep 2009 and 1 Jun 2010: "Date: Date (node) Content: Date (field_event_datetime) - From date between 2009-09-01 00:00:00 and 2010-06-01 00:00:00". All my dates are between 1 Sep 2009 and 1 Jun 2010 so the query should show ten items.

Ok, here's the interesting thing. The preview pane shows this as the db query:

SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_event_datetime.field_event_datetime_value AS node_data_field_event_datetime_field_event_datetime_value,
   node_data_field_event_datetime.field_event_datetime_value2 AS node_data_field_event_datetime_field_event_datetime_value2,
   node.type AS node_type,
   node.vid AS node_vid
 FROM node node 
 LEFT JOIN content_type_event node_data_field_event_datetime ON node.vid = node_data_field_event_datetime.vid
 WHERE (DATE_FORMAT(ADDTIME(node_data_field_event_datetime.field_event_datetime_value, SEC_TO_TIME(-14400)), '%Y-%m-%%d') >= '2009-09-01' AND DATE_FORMAT(ADDTIME(node_data_field_event_datetime.field_event_datetime_value, SEC_TO_TIME(-14400)), '%Y-%m-%%d') <= '2010-06-01') OR ((DATE_FORMAT(ADDTIME(node_data_field_event_datetime.field_event_datetime_value, SEC_TO_TIME(-14400)), '%Y') <= '2009' AND DATE_FORMAT(ADDTIME(node_data_field_event_datetime.field_event_datetime_value2, SEC_TO_TIME(-14400)), '%Y') >= '2009'))
   ORDER BY node_data_field_event_datetime_field_event_datetime_value ASC

and the preview pane shows the first 7 dates, converted to ical format. Which is exactly what my users see when they subscribe to the feed at calendar/ical

But if I cut and paste the EXACT SAME query into the mysql command line, I get all ten dates (the correct answer):

+-----+--------------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+-----------+----------+
| nid | node_title                                       | node_data_field_event_datetime_field_event_datetime_value | node_data_field_event_datetime_field_event_datetime_value2 | node_type | node_vid |
+-----+--------------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+-----------+----------+
|  25 | Ski Testing & Grinding                           | 2009-10-05 18:00:00                                       | 2009-10-05 22:30:00                                        | event     |       25 | 
|  26 | Bruce Ski Club Executive Meeting                 | 2009-10-15 23:00:00                                       | 2009-10-16 01:00:00                                        | event     |       26 | 
|  23 | Sawmill Trail Work Party                         | 2009-10-18 16:00:00                                       | 2009-10-18 20:00:00                                        | event     |       23 | 
|  30 | Southern Ontario District Annual General Meeting | 2009-10-18 17:00:00                                       | 2009-10-18 19:00:00                                        | event     |       30 | 
|  32 | Rankin Trail Work Party                          | 2009-10-24 14:00:00                                       | 2009-10-24 18:00:00                                        | event     |       32 | 
|  24 | Ski Swap at Suntrail                             | 2009-11-07 14:00:00                                       | 2009-11-07 17:00:00                                        | event     |       24 | 
|  27 | Early Bird Registration Deadline                 | 2009-11-15 17:00:00                                       | 2009-11-15 17:00:00                                        | event     |       27 | 
|  31 | Ski Exchange with Sauble Ski Club                | 2010-01-23 05:00:00                                       | 2010-01-30 04:59:00                                        | event     |       31 | 
|  28 | Suntrail Special 2010                            | 2010-02-07 15:00:00                                       | 2010-02-07 18:00:00                                        | event     |       28 | 
|  29 | Winterama                                        | 2010-02-13 15:00:00                                       | 2010-02-13 18:00:00                                        | event     |       29 | 
+-----+--------------------------------------------------+-----------------------------------------------------------+------------------------------------------------------------+-----------+----------+
10 rows in set (0.01 sec)

Something in Views or Calendar seems to be trimming the database output. If I change the date of the Jan 2010 event to Dec 2009, it will show up in the calendar/ical feed (as a Dec 2009 event) even though the query in the preview pane has not changed.

I upgraded the calendar module to the most recent dev version and the problem persists. Caching is turned off.

So, either the query shown in the preview is incorrect, or something is messing with the data returned by the query. I don't know enough php to mess around with the Views or Calendar modules. Hopefully I've provided enough clues for someone to find the bug.

thank again for all your hard work,
Andrew Howlett.

bwynants’s picture

it is not the 'Basic settings' 'Items to display: 7' setting in the view?

Andrew Howlett’s picture

no, set to unlimited. when i change the Jan 2010 event to Dec it displays 8 items, so it isn't limited by quantity.

bwynants’s picture

Gribnif’s picture

@Andrew Howlett: I think the very problem addressed by the patches in this thread could be what you're hitting. At the very least, try commenting out the lines suggested in #5.

monjohn’s picture

Is this patch ready to be applied?

michellezeedru’s picture

Just want to say thank you so much! I have an iCal feed that has been broken for some time now, and the patch in #12 fixed the problem. Thanks!

movinr8along’s picture

Status: Needs review » Reviewed & tested by the community

Tried the solution referenced in #13 and can say Gribnif's solution in #12 works much better. This solved the problem completely and I would recommend it be applied as a resolution of this bug.

dnotes’s picture

Title: iCal Feed Not Showing Repeating Events Which Start Before The View Window » iCal Feed Not Working for Recurring Events (Repeating Events Which Start Before The View Window, Only One Event Shown)
Issue tags: +ical, +repeating date
FileSize
722 bytes

I made an update of the patch from comment #12 with the line numbers from the Oct.22 dev version - hoping to test it later today in drush make file, since this is an important part of my install profile. Also, I was wondering about the purpose of removing the _rrule query generators from earlier on in the file, and it seems like that would be a separate issue so I removed it from this patch. I don't care which patch gets applied, but I believe that ical feeds with recurring events are a pretty crucial bit of functionality, and I just don't see how the current code can work as it tries to key an array by a value that can be the same for every row in the query.

I am changing the title because this fix addresses a number of problems that people have been experiencing with ical feeds in general; for example, I first came to this after #637890: iCal: Only showing first found repeating (rrule) event, which I have since marked as a duplicate. There were also a number of people with the same problem who went to #446614: iCal empty, and there appear to be several other issues on this same theme. If I read right, this may qualify as a "major" issue, given that it seems to be something that breaks a major part of the calendar in a significant number of cases.

markhalliwell’s picture

I can confirm that #23 worked for me. My iCal is now showing repeating events!!!! Yay thank you! Commit!!!

KarenS’s picture

Status: Reviewed & tested by the community » Fixed

Finally got this committed. Thanks!

Status: Fixed » Closed (fixed)

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

Caseinpoint’s picture

Having same issue. Subscribed.

Caseinpoint’s picture

Does anyone else have a problem with events that repeat once every week and span several months? Mine just don't seem to sync back to my Drupal calendar.