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

Issue fork views_ical-3281261

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

norwegian.blue created an issue. See original summary.

norwegian.blue’s picture

OK - 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.

norwegian.blue’s picture

The attached patch seems to have resolved the issue for me.

norwegian.blue’s picture

Patch in #3 threw warning

Rerolled

norwegian.blue’s picture

StatusFileSize
new588 bytes

Wrong patch file uploaded in #4. (patch wouldn't apply)
Corrected.

bburg’s picture

Looks 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.

bburg’s picture

On 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.

norwegian.blue’s picture

Agree with both your comments (#6 & #7) bburg.

I'm leaving mine as is until you commit.

sclsweb’s picture

When 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.

sclsweb’s picture

Issue tags: +Needs reroll

immaculatexavier made their first commit to this issue’s fork.

immaculatexavier’s picture

Status: Active » Needs review

Rerolled for 8.x. kindly review

sclsweb’s picture

I 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):

  • The view uses only a smart date field mapped to Date field, End date field, and All day field; Title (mapped to Summary), a location text field (mapped to Location); and Body (mapped to Description).
  • In the iCal Feed style options, UID field can be mapped to None.
  • Aggregate the view
  • On the smart date field Aggregation settings, Group results together with the Group column set to Entity ID (NOT Value).
  • Remove any Sort criteria (my test view inherited sort criteria from the default display, and it created duplicates for me).
mfb’s picture

If 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.