From cs at nnix.de Mon Apr 15 08:39:04 2024 From: cs at nnix.de (Christian Schwamborn) Date: Mon, 15 Apr 2024 10:39:04 +0200 Subject: [Kolab-devel] libcalendaring trace due to a faulty event Message-ID: <159b24e8-0d92-fb51-1cf3-579b8bff073c@nnix.de> Hello List, playing around with your calendar plugin and the newly implemented caldav driver (thank you alec), I got a trace whenI connected my test system with actual calendar data from a (nextcloud) life system. 14-Apr-2024 09:58:37 UTC] PHP Fatal error: Uncaught Sabre\VObject\Recur\NoInstancesException: This recurrence rule does not generate any valid instances in /usr/local/share/roundcube/plugins/carddav/vendor/sabre/vobject/lib/Recur/EventIterator.php:192 Stack trace: #0 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libcalendaring/lib/libcalendaring_recurrence.php(85): Sabre\VObject\Recur\EventIterator->__construct() #1 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libcalendaring/lib/libcalendaring_recurrence.php(56): libcalendaring_recurrence->init() #2 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libcalendaring/libcalendaring.php(197): libcalendaring_recurrence->__construct() #3 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libkolab/lib/kolab_storage_dav_cache_event.php(44): libcalendaring::get_recurrence() #4 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libkolab/lib/kolab_storage_dav_cache.php(514): kolab_storage_dav_cache_event->_serialize() #5 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libkolab/lib/kolab_storage_dav_cache.php(177): kolab_storage_dav_cache->_extended_insert() #6 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libkolab/lib/kolab_storage_dav_cache.php(90): kolab_storage_dav_cache->synchronize_worker() #7 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libkolab/lib/kolab_storage_folder.php(319): kolab_storage_dav_cache->synchronize() #8 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/calendar/drivers/caldav/caldav_calendar.php(259): kolab_storage_folder->select() #9 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/calendar/drivers/caldav/caldav_driver.php(536): caldav_calendar->list_events() #10 /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/calendar/calendar.php(1656): caldav_driver->load_events() #11 /usr/share/roundcube/program/lib/Roundcube/rcube_plugin_api.php(520): calendar->refresh() #12 /usr/share/roundcube/program/include/rcmail.php(292): rcube_plugin_api->exec_hook() #13 /usr/share/roundcube/index.php(278): rcmail->action_handler() #14 /var/lib/roundcube/public_html/index.php(26): include('...') #15 {main} thrown in /usr/local/share/roundcube/plugins/carddav/vendor/sabre/vobject/lib/Recur/EventIterator.php on line 192 Poking around I was able to identify the event in question, no clue how it got ever into a calendar as even the summary is missing. Only Apple clients show that event, but non of the clients I use even displayed that one. BEGIN:VEVENT TRANSP:OPAQUE DTEND;TZID=Europe/Berlin:20210606T093000 RDATE:20210604T073000Z UID:fb1cb690-b963-4ea5-b58f-ac9773e36d9a EXDATE;TZID=Europe/Berlin:20210604T093000 DTSTAMP:20210528T091628Z X-MOZ-FAKED-MASTER:1 X-MOZ-GENERATION:1 SEQUENCE:1 X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC SUMMARY: LAST-MODIFIED:20210528T091628Z CREATED:20210528T091213Z DTSTART;TZID=Europe/Berlin:20210604T093000 END:VEVENT As the sync process took a long time and was seemingly stuck in a loop due to this issue, I came up with a ugly patch as I have very little understanding of the workings of that plugin. But at least the sync finishes now. diff --git a/plugins/libcalendaring/lib/libcalendaring_recurrence.php b/plugins/libcalendaring/lib/libcalendaring_recurrence.php index 3b06bd01..e819ad1e 100644 --- a/plugins/libcalendaring/lib/libcalendaring_recurrence.php +++ b/plugins/libcalendaring/lib/libcalendaring_recurrence.php @@ -82,7 +82,12 @@ class libcalendaring_recurrence $ve = $vcalendar->toSabreComponent($event); - $this->engine = new EventIterator($ve, null, $this->lib->timezone); + try { + $this->engine = new EventIterator($ve, null, $this->lib->timezone); + } catch (Exception $e) { + $this->engine = null; + rcube::write_log('dav', 'error in event: ' . $this->event['href']); + } } /** @@ -114,6 +119,7 @@ class libcalendaring_recurrence // should return 11th as next_instance() when called for the first time. // Looks like Sabre is setting internal "current date" to 11th on such an object // initialization, therefore calling next() would move it to 12th. + if ($this->engine == null) return false; if ($this->isStart && ($next_start = $this->engine->getDtStart()) && $next_start->format('Ymd') != $this->start->format('Ymd') ) { This is most probably not a production stable fix as it causes further warnings, but I'm sure someone will know a proper way to handle this, i.e. creating an save and empty iterator. [15-Apr-2024 07:44:03 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /usr/local/share/roundcube/plugins/roundcubemail-plugins-kolab/plugins/libcalendaring/lib/libcalendaring_recurrence.php on line 168 Even if all of this is caused by a broken event, I guess the code should not trace. Cheers Chris From machniak at apheleia-it.ch Thu Apr 18 11:54:54 2024 From: machniak at apheleia-it.ch (Aleksander Machniak) Date: Thu, 18 Apr 2024 13:54:54 +0200 Subject: [Kolab-devel] libcalendaring trace due to a faulty event In-Reply-To: <159b24e8-0d92-fb51-1cf3-579b8bff073c@nnix.de> References: <159b24e8-0d92-fb51-1cf3-579b8bff073c@nnix.de> Message-ID: <33811c10-9823-4732-98b6-52155b3d710b@apheleia-it.ch> On 15.04.2024 10:39, Christian Schwamborn wrote: > Hello List, > > playing around with your calendar plugin and the newly implemented > caldav driver (thank you alec), I got a trace whenI connected my test > system with actual calendar data from a (nextcloud) life system. > > 14-Apr-2024 09:58:37 UTC] PHP Fatal error: Uncaught > Sabre\VObject\Recur\NoInstancesException: This recurrence rule does not > generate any valid instances in > /usr/local/share/roundcube/plugins/carddav/vendor/sabre/vobject/lib/Recur/EventIterator.php:192 Thanks for the report. I fixed the issue in https://git.kolab.org/rRPK4f8869529e27f104f281a565f274f697e07144fa -- Aleksander Machniak Senior Software Engineer Apheleia IT AG PGP: 19359DC1 -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: