Problem/Motivation
Events created with SmartDate which recur get multiple instances in the created ical file.
NOTE: This appears to be a duplicate of 3231318. However with the patch installed the problem still exists.
Steps to reproduce
-
- Create view Format iCal Style Wizard
- Include the date (SmartDate) and Title
- Map the Date to the SmartDate field
- Create and event with a fixed duration that repeats (eg every day for three occurrences)
Result
The recurring event is created in the ical file multiple times - if there are three occurrences, there are three instances in the ical:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Drupal iCal API//EN
X-WR-CALNAME:Te Anau Events
BEGIN:VEVENT
UID:628579e193d4d
DTSTART;VALUE=DATE:20220517
SEQUENCE:0
TRANSP:TRANSPARENT
DTEND;VALUE=DATE:20220522
SUMMARY: Test-repeat
CLASS:PUBLIC
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
DTSTAMP:20220518T225737Z
END:VEVENT
BEGIN:VEVENT
UID:628579e194736
DTSTART;TZID=Pacific/Auckland:20220524T170000
SEQUENCE:0
TRANSP:TRANSPARENT
DTEND;TZID=Pacific/Auckland:20220524T173000
SUMMARY: Recurring test
CLASS:PUBLIC
RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
DTSTAMP:20220518T225737Z
END:VEVENT
BEGIN:VEVENT
UID:628579e195a88
DTSTART;TZID=Pacific/Auckland:20220524T170000
SEQUENCE:0
TRANSP:TRANSPARENT
DTEND;TZID=Pacific/Auckland:20220524T173000
SUMMARY: Recurring test
CLASS:PUBLIC
RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
DTSTAMP:20220518T225737Z
END:VEVENT
BEGIN:VEVENT
UID:628579e195e58
DTSTART;TZID=Pacific/Auckland:20220524T170000
SEQUENCE:0
TRANSP:TRANSPARENT
DTEND;TZID=Pacific/Auckland:20220524T173000
SUMMARY: Recurring test
CLASS:PUBLIC
RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
DTSTAMP:20220518T225737Z
END:VEVENT
BEGIN:VEVENT
UID:628579e19699a
DTSTART;TZID=Pacific/Auckland:20220625T193000
SEQUENCE:0
TRANSP:TRANSPARENT
DTEND;TZID=Pacific/Auckland:20220625T230000
SUMMARY: The Milford Crew
CLASS:PUBLIC
DTSTAMP:20220518T225737Z
END:VEVENT
END:VCALENDAR
Environment
OS: Fedora Linux
PHP 8.0.18
DB: MariaDB 10.5.13
Drupal: 9.3.11
views_ical 1.0.0-alpha8 with 3231318-4.patch (result is the same with latest dev)
views_ical install record
- Upgrading drupal/views_ical (dev-1.x b8d990b => 1.0.0-alpha8)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches from patch file.
Gathering patches for dependencies. This might take a minute.
- Installing drupal/views_ical (1.0.0-alpha8): Extracting archive
- Applying patches for drupal/views_ical
https://www.drupal.org/files/issues/2021-10-03/views_ical-duplicate-smart-date-events-3231318-4.patch (Smart Date - Recurring Dates cause duplicates - 3231318)
Related
3231318
3277098
Comments
Comment #2
norwegian.blue commentedOK - further investigation.
Using SmartDate, recurring dates creates multiple records in `node__field_when` - if there are three events, there are three records. These each have a unique `field_when_rrule_index`, so SELECT DISTICT still returns multiple rows.
Thus a view returns one row per recurrence of the event.
The patch in 3231318 prevents the rrule of a row retrieved by the view generating multiple rows in the iCal output by checking if the rrule has been processed, but $processedRules is initialised for each row retrieved by the view, so there are still multiple iCal rows output.
Comment #3
norwegian.blue commentedThe attached patch seems to have resolved the issue for me.
Comment #4
norwegian.blue commentedPatch in #3 threw warning
Rerolled
Comment #5
norwegian.blue commentedWrong patch file uploaded in #4. (patch wouldn't apply)
Corrected.
Comment #6
bburgLooks good, and simple enough. I'm doing some other work on the module this week, so I'll get it committed if it works for you.
I might suggest using drupal_static, though I don't see much of a use case for needing this beyond just standard practice within Drupal.
Comment #7
bburgOn second thought, I think we should probably namespace that static variable with something more unique. We can't be sure "$processedResults" isn't declared statically somewhere else.
Comment #8
norwegian.blue commentedAgree with both your comments (#6 & #7) bburg.
I'm leaving mine as is until you commit.
Comment #9
sclsweb commentedWhen updating to views_ical 1.0.0-alpha10, Composer says it cannot apply the patch from #5.
If you can provide an updated patch I can try to test it.
Comment #10
sclsweb commentedComment #13
immaculatexavier commentedRerolled for 8.x. kindly review
Comment #14
sclsweb commentedI found a way to get the recurring smart dates to display one item per date with a unique UID, without any patches. Posting this in case it helps anyone else (including my future self):
Comment #15
mfbIf the UID is None, i.e. NULL, then it appears to be auto-generated using the uniqid() function - which means it changes every time the calendar feed is regenerated. This means that a new event will be created by calendar feed subscribers. So, that's just not going to work.