u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
453 stars 145 forks source link

Event recurrences appear twice if moved #341

Open sergentrif opened 2 months ago

sergentrif commented 2 months ago

PHP Version

8.3

PHP date.timezone

Europe/Paris

ICS Parser Version

3.4

Operating System

Mac

Description

I moved the recurrence of an event and now this recurrence appears twice in the events that are loaded.

It first appears on the correct date (the last, after moving), but it still appears on its initial date.

My event is as follows

BEGIN:VEVENT
DTSTART;TZID=Europe/Paris:20240910T140000
DTEND;TZID=Europe/Paris:20240910T173000
DTSTAMP:20240912T131820Z
UID:FAKE-UID
RECURRENCE-ID;TZID=Europe/Paris:20240911T090000
CREATED:20240311T155453Z
LAST-MODIFIED:20240911T162406Z
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY: FAKE-NAME
TRANSP:OPAQUE
CATEGORIES:2
END:VEVENT

Lines 1307 and 1308 of the ICal.php file seem suspicious to me, as they imply that we're going to replace the DTSTART date of the recurrence with the date contained in the RECURRENCE-ID field.

protected function processEvents()
{
    ...        
    $recurrenceDateUtc = $this->iCalDateToUnixTimestamp($anEvent['RECURRENCE-ID_array'][3]);
    $this->alteredRecurrenceInstances[$uid][$key] = $recurrenceDateUtc;
    ...
}

However, this initial date is now just an ID, since the recurrence has been moved. Even if these lines are modified, the problem remains. No matter how hard I try, I have to admit that I'm powerless to fix this bug.

Steps to Reproduce

You can use the following event

BEGIN:VEVENT
DTSTART;TZID=Europe/Paris:20240910T140000
DTEND;TZID=Europe/Paris:20240910T173000
DTSTAMP:20240912T131820Z
UID:FAKE-UID
RECURRENCE-ID;TZID=Europe/Paris:20240911T090000
CREATED:20240311T155453Z
LAST-MODIFIED:20240911T162406Z
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY: FAKE-NAME
TRANSP:OPAQUE
CATEGORIES:2
END:VEVENT