[Kolab-devel] libcalendaring trace due to a faulty event

Christian Schwamborn cs at nnix.de
Mon Apr 15 08:39:04 UTC 2024


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



More information about the devel mailing list