u01jmg3 / ics-parser

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

Undefined index: DTSTART_array #122

Closed spalberg closed 7 years ago

spalberg commented 7 years ago

Hello again, first things first: this time I'm using the latest dev-master ;)

When I try to import a specific ics-file I get the following error:

PHP Notice:  Undefined index: DTSTART_array in /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php on line 671
PHP Stack trace:
PHP   1. {main}() /var/www/html/cli.php:0
PHP   2. ICal\ICal->__construct() /var/www/html/cli.php:192
PHP   3. ICal\ICal->initLines() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:185
PHP   4. ICal\ICal->processRecurrences() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:319
PHP Notice:  Undefined index: DTSTART_array in /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php on line 673
PHP Stack trace:
PHP   1. {main}() /var/www/html/cli.php:0
PHP   2. ICal\ICal->__construct() /var/www/html/cli.php:192
PHP   3. ICal\ICal->initLines() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:185
PHP   4. ICal\ICal->processRecurrences() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:319
PHP Notice:  Undefined index: DTSTART_array in /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php on line 708
PHP Stack trace:
PHP   1. {main}() /var/www/html/cli.php:0
PHP   2. ICal\ICal->__construct() /var/www/html/cli.php:192
PHP   3. ICal\ICal->initLines() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:185
PHP   4. ICal\ICal->processRecurrences() /var/www/html/vendor/johngrogg/ics-parser/src/ICal/ICal.php:319

The ics-file causing this issue:

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Ximian//NONSGML Evolution Calendar//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:/freeassociation.sourceforge.net/Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:STANDARD
TZNAME:CET
DTSTART:19701029T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
DTSTART:19700326T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:20170402T151449Z-14010-1000-1-3@arch-linux
DTSTAMP:20170402T121314Z
DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Berlin:
 20170406T100000
DTEND;TZID=/freeassociation.sourceforge.net/Europe/Berlin:
 20170406T133000
SEQUENCE:3
SUMMARY:linux
TRANSP:OPAQUE
CLASS:PUBLIC
CREATED:20170402T151514Z
LAST-MODIFIED:20170402T151529Z
RRULE;X-EVOLUTION-ENDDATE=20170629T080000Z:FREQ=WEEKLY;COUNT=13;BYDAY=TH
END:VEVENT
END:VCALENDAR

Seems like the DTSTART and DTEND keys are "dropped" since the actual datetime-string is in the following line.

u01jmg3 commented 7 years ago

Thanks

spalberg commented 7 years ago

Thanks for the fast response!

I removed the second event (no errors). The resulting file with the first event is still causing errors for me.

issue.txt

I tried opening via your constructor and the filepath:

$ical = new ICal\ICal($filePath, [
    'defaultWeekStart' => 'MO',
]);

and also opening and splitting it myself and calling your constructor with the resulting string array:

$ical = new ICal\ICal(explode("\n", $icsString), [
    'defaultWeekStart' => 'MO',
]);

Both ways result in the given error.

Just to be sure I checked the code of ICal.php against your current commit (07e775f): identical.

u01jmg3 commented 7 years ago

spalberg commented 7 years ago

Edit: Found the "error". I am running php inside a docker container. I simply recreated the container (used it for a while) and your code runs without errors. I don't exactly know what caused the issue with my "used" container but something sure did... Sorry for taking up your time!