6.0.0-beta1
8/10/25

[#12801] Unable to parse recurring events during iCalendar import
Summary Unable to parse recurring events during iCalendar import
Queue Kronolith
Queue Version 4.1.3
Type Bug
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester wrcdrijfhout (at) imperamus (dot) eu
Created 10/28/2013 (4304 days ago)
Due
Updated 11/03/2013 (4298 days ago)
Assigned
Resolved 10/29/2013 (4303 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
11/03/2013 02:58:10 PM wrcdrijfhout (at) imperamus (dot) eu Comment #6 Reply to this comment
I suggest the following generalization:
`
$vEventException_r = $exceptionEvent->toiCalendar($calendar);

[Show Quoted Text - 13 lines]
11/03/2013 02:55:17 PM wrcdrijfhout (at) imperamus (dot) eu Comment #5 Reply to this comment
* The ICAL-URL is completely empty, supposedly because PHP's request
handling died prematurely.

I will contact Jan via e-mail about a larger ICS-file with which the
problem can be reproduced.
Works perfectly fine for me with a current Horde checkout even with 
the other ICS file.
While I do not run the latest Horde checkout, I backported the fix you 
committed. The problem persists; I traced it to an OutOfMemory-problem:

In kronolith/lib/Api.php, line 896 onward, I wrote:
`$i=-1;
             foreach ($events as $dayevents) {
print(++$i.'<br/>');
print((memory_get_usage()/1024/1024).'MB / '. ini_get('memory_limit') 
. '<br/>');
                 foreach ($dayevents as $event) {
                     $iCal->addComponent($event->toiCalendar($iCal));
                 }
             }
die();
`

From this I deduced I exceeded the memory limit. I find it dubious 
that experting a mere 100 calendar entries would require 184MB to 
yield a 2.9MB file; can we optimize this?

In Icalendar.php, we can (at least) do this:
`
     public function addComponent(&$components)
     {
         if (is_array($components)) {
             foreach ($components as &$component) {
                 $this->addComponent($component);
             }
         } else if ($components instanceof Horde_Icalendar) {
             $components->_container = &$this;
             $this->_components[] = &$components;
         }
     }

`
Notice the ampersands; i.e., by-reference/address-of operator. The 
line "$this->_components[] = &$component;" is still the most expensive 
one. Anyhow, by replacing addComponent as such, we cut down memory 
usage from 184MB to 53MB (and gain more performance as well)!

I recommend exploring further applications of passing values 
by-reference (by using the &-operator) instead of by-value throughout 
Horde (especially oft-used functions, like domain-entity functions).




-----------


Also, the previous fix for kronolith/lib/Event.php you added checks 
for the Timezone-object being at index 0 or 1, but array_pop always 
retrieves the object at the last index (rather than the non-Timezone 
index). I suggest the following generalization:
`
                     foreach ($vEventException_r as $key => &$vEE){
                         if ($vEE instanceof Horde_Icalendar_Vtimezone){
                             unset($vEventException_r[$key]);
                         }
                     }
                     // This should never happen, but protect against 
it anyway.
                     if (count($vEventException_r) > 1) {
                         throw new Kronolith_Exception(_("Unable to 
parse event."));
                     }
                     $vEventException = array_pop($vEventException_r);
`
10/30/2013 11:14:16 AM Jan Schneider Comment #4 Reply to this comment
[jan] Fix fatal error if recurrence exceptions have timezones set
(Bug #12801).
Alas, it seems the problem is not completely solved.

* CalDAV counts 551 entries in its index, while the database and 
source ICS-file contain 595 entries. Unless not all VEVENT-objects 
should be in the index, there is still a problem here.
This is fine, exceptions to recurring events are separate VEVENT entries.
* The ICAL-URL is completely empty, supposedly because PHP's request 
handling died prematurely.

I will contact Jan via e-mail about a larger ICS-file with which the 
problem can be reproduced.
Works perfectly fine for me with a current Horde checkout even with 
the other ICS file.
10/29/2013 07:11:25 PM wrcdrijfhout (at) imperamus (dot) eu Comment #3 Reply to this comment
[jan] Fix fatal error if recurrence exceptions have timezones set 
(Bug #12801).
Alas, it seems the problem is not completely solved.

* CalDAV counts 551 entries in its index, while the database and 
source ICS-file contain 595 entries. Unless not all VEVENT-objects 
should be in the index, there is still a problem here.
* The ICAL-URL is completely empty, supposedly because PHP's request 
handling died prematurely.

I will contact Jan via e-mail about a larger ICS-file with which the 
problem can be reproduced.
10/29/2013 05:47:57 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
 
10/29/2013 05:46:15 PM Git Commit Comment #2 Reply to this comment
Changes have been made in Git (master):

commit ecd18ac4f04036cf6cede10be1c30c5d901edc5c
Author: Jan Schneider <jan@horde.org>
Date:   Tue Oct 29 18:44:02 2013 +0100

     [jan] Fix fatal error if recurrence exceptions have timezones set 
(Bug #12801).

  kronolith/docs/CHANGES  |    1 +
  kronolith/lib/Event.php |    5 ++++-
  kronolith/package.xml   |    4 ++--
  3 files changed, 7 insertions(+), 3 deletions(-)

http://git.horde.org/horde-git/-/commit/ecd18ac4f04036cf6cede10be1c30c5d901edc5c
10/29/2013 08:55:04 AM Jan Schneider Priority ⇒ 2. Medium
 
10/29/2013 08:54:21 AM Jan Schneider Deleted Original Message
 
10/28/2013 12:13:50 PM wrcdrijfhout (at) imperamus (dot) eu Comment #1 (Private)
Priority ⇒ 3. High
Type ⇒ Bug
Summary ⇒ Unable to parse recurring events during iCalendar import
Queue ⇒ Kronolith
Milestone ⇒
Patch ⇒ No
New Attachment: Hobby.ics
State ⇒ Unconfirmed
[Hidden]

Saved Queries