u01jmg3 / ics-parser

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

Fix removing double event entries #258

Closed DavidBadura closed 4 years ago

DavidBadura commented 4 years ago

With PHP 7.4 I get the following error Notice: Trying to access array offset on value of type null when the ics file has duplicate event entries. Here the event really has to be removed and not set to null.

DavidBadura commented 4 years ago

Here is an example:

BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Homeoffice
X-WR-TIMEZONE:Europe/Berlin
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20200122T040000
DTEND;TZID=Europe/Berlin:20200122T073000
RRULE:FREQ=WEEKLY;BYDAY=WE
DTSTAMP:20200206T122832Z
UID:7pfk8pe2ft8vud6j5k019lhsd6@google.com
CREATED:20200121T100713Z
DESCRIPTION:
LAST-MODIFIED:20200121T101524Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Homeofficetest
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20200122T070000Z
DTEND:20200122T080000Z
DTSTAMP:20200206T122832Z
UID:6n2teso468j7jnqfctu9t8hvj2@google.com
CREATED:20200121T135656Z
DESCRIPTION:
LAST-MODIFIED:20200121T135656Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20200123T113000
DTEND;TZID=Europe/Berlin:20200124T123000
RRULE:FREQ=WEEKLY;BYDAY=TH
DTSTAMP:20200206T122832Z
UID:6dk289f1kstq186c7gt5nuu047@google.com
CREATED:20200121T100749Z
DESCRIPTION:
LAST-MODIFIED:20200123T124107Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20200124T023000
DTEND;TZID=Europe/Berlin:20200124T061500
RRULE:FREQ=WEEKLY;BYDAY=FR
DTSTAMP:20200206T122832Z
ORGANIZER;CN=Homeoffice:mailto:example.com_d62fi9c5etqbnnubnc2fbavmmk@g
 roup.calendar.google.com
UID:0b3j0l89ucb9og3o073m59fbuu@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=DECLINED;CN=david.
 badura@example.com;X-NUM-GUESTS=0:mailto:david.badura@example.com
CREATED:20200123T085851Z
DESCRIPTION:
LAST-MODIFIED:20200128T160813Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Homeoffice
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20200124T023000
DTEND;TZID=Europe/Berlin:20200124T061500
DTSTAMP:20200206T122832Z
ORGANIZER;CN=Homeoffice:mailto:example.com_d62fi9c5etqbnnubnc2fbavmmk@g
 roup.calendar.google.com
UID:0b3j0l89ucb9og3o073m59fbuu@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=DECLINED;CN=david.
 badura@example.com;X-NUM-GUESTS=0:mailto:david.badura@example.com
RECURRENCE-ID;TZID=Europe/Berlin:20200124T023000
CREATED:20200123T085851Z
DESCRIPTION:
LAST-MODIFIED:20200128T160813Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Homeoffice
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20200206T023000Z
DTEND:20200206T054500Z
DTSTAMP:20200206T122832Z
UID:13hp7hh3i1lhmpklulduvktjua@google.com
CREATED:20200206T122815Z
DESCRIPTION:
LAST-MODIFIED:20200206T122815Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Hometest
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
u01jmg3 commented 4 years ago

Perfect - was about to ask for test iCal.

u01jmg3 commented 4 years ago

This change appears to upset the total number of events count as it incorrectly increases by 1.

For example, with your code change and attached iCal I get a count of 324 (which is wrong) but without your code change I get a count of 323 (which is correct).

u01jmg3 commented 4 years ago

Closing in favour of 94aba50 which prevents the counting issue I noted previously with this PR.

lucianholt97 commented 4 years ago

@u01jmg3 somehow I don't get the proposed changes when installing v2.1.17 via composer. Comparing the source code which I have locally and the one on GitHub, I spotted a few differences. Is it necessary to add another version to this change in order to be mirrored to composer?

u01jmg3 commented 4 years ago

Shall create a new release in due course. In the meantime you can use dev-master in composer.json.