6.0.0-beta1
7/25/25

[#5980] Import of events via sync fails caused by empty uid
Summary Import of events via sync fails caused by empty uid
Queue Kronolith
Queue Version 2.2-RC1
Type Bug
State Not A Bug
Priority 2. Medium
Owners
Requester xk3 (at) mompl (dot) org
Created 12/09/2007 (6438 days ago)
Due
Updated 12/16/2007 (6431 days ago)
Assigned 12/10/2007 (6437 days ago)
Resolved 12/16/2007 (6431 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
12/16/2007 12:16:34 PM Jan Schneider State ⇒ Not A Bug
 
12/16/2007 11:39:52 AM xk3 (at) mompl (dot) org Comment #8 Reply to this comment
yes, it seems to be a problem of this particular php version (current 
stable/SecurityFix of debian), I could reproduce it on a different 
machine.



However, upgrading to 5.2.3-1 solved it.

Thanks for taking your time.
12/16/2007 11:04:38 AM Jan Schneider Comment #7 Reply to this comment
I can't reproduce that segfault.
Me neither. A segfault in an internal PHP method is always PHP's fault anyway.
12/15/2007 05:34:34 PM Chuck Hagenbuch Comment #6 Reply to this comment
I can't reproduce that segfault.
12/14/2007 09:57:19 PM xk3 (at) mompl (dot) org Comment #5 Reply to this comment
got it! Was hidden in logMessage that I did not suspect till now.



in kronolith/lib/Driver/sql.php

function &getByUID

    $values = array($uid);

    /* Log the query at a DEBUG log level. */

    Horde::logMessage(sprintf('Kronolith_Driver_sql::getByUID(): user 
= "%s"; query = "%s"; values = "%s"',

Auth::getAuth(), $query, implode(',', $values)),



The sprintf causes a segfault, if $uid === null (which it is in my 
case). Skipping the logMessage the event is correctly imported.



Test script:



<?php

$uid = null;

echo "XXX 0 \n";

$values = array($uid);

echo "XXX 1 \n";

$tmp = sprintf('Kronolith_Driver_sql::getByUID(): user = "%s"; query = 
"%s"; values = "%s"',

                'myID', 'query', implode(',', $values));

echo "XXX 2 \n";

?>



gives:

XXX 0

XXX 1

Segmentation fault





PHP Version 5.2.0-8+etch7 (debian)

eAccelerator switched off
12/14/2007 01:31:36 AM Jan Schneider Comment #4 Reply to this comment
Following your description closely, I can not see how this script could "die".



In Kronolith_Driver_sql::getByUID() the query fails, 
$this->_db->getAll() returns a PEAR_Error that is passed back to 
_kronolith_import() where we continue if getByUID() returned a 
PEAR_Error.
12/11/2007 06:55:38 PM xk3 (at) mompl (dot) org Comment #3 Reply to this comment
yes.



An event Test1 created by kronolith can be synced to the mobile, 
changed there and synced back.



input received from client (text/calendar)

BEGIN:VCALENDAR

VERSION:1.0

BEGIN:VEVENT

UID:11122007180821730250-0

SUMMARY:Test1 changed

DTSTART:20071211T060000

DTEND:20071211T070000

X-EPOCAGENDAENTRYTYPE:APPOINTMENT

CLASS:PUBLIC

SEQUENCE:0

X-METHOD:NONE

LAST-MODIFIED:20071211T181624Z

PRIORITY:0

X-SYMBIAN-LUID:30

END:VEVENT

END:VCALENDAR



The following event Test3 was created on the mobile and lets horde 
quietly die.



input received from client (text/calendar)

BEGIN:VCALENDAR

VERSION:1.0

BEGIN:VEVENT

UID:ZE6hKA8J4EC2f46AwB4iV1

SUMMARY:Test3

DTSTART:20071211T090000Z

DTEND:20071211T100000Z

X-EPOCAGENDAENTRYTYPE:APPOINTMENT

CLASS:PRIVATE

SEQUENCE:0

X-METHOD:NONE

LAST-MODIFIED:20071211T181040Z

PRIORITY:2

X-SYMBIAN-LUID:32

END:VEVENT

END:VCALENDAR
12/10/2007 11:05:23 AM Jan Schneider Comment #2
State ⇒ Feedback
Priority ⇒ 2. Medium
Reply to this comment
As I understand, there are two bugs: we fail if can't retrieve a uid. 
And we don't retrieve this event's uid properly. Right?
12/09/2007 05:10:55 PM xk3 (at) mompl (dot) org Comment #1
Priority ⇒ 3. High
State ⇒ Unconfirmed
Queue ⇒ Kronolith
Summary ⇒ Import of events via sync fails caused by empty uid
Type ⇒ Bug
Reply to this comment
Doing a trace:



$item is a SyncML_SyncElement Object

(

     [_elementType] => Add

     [_cuid] => 22

     [_contentType] =>

     [_content] => BEGIN:VCALENDAR

VERSION:1.0

BEGIN:VEVENT

UID:09122007151253499125-0

[snip]



coming from horde sync and doing a krontolith import via api

/horde/kronolith/lib/api.php

     function _kronolith_import($content, $contentType, $calendar = null)

         [snip]

         $event->fromiCalendar($content);



The $item itself contains an UID, but it got stripped for $content by 
horde sync.

/horde/kronolith/lib/Driver.php

     function fromiCalendar($vEvent) in

         $uid = $vEvent->getAttribute('UID');

         if (!empty($uid) && !is_a($uid, 'PEAR_Error')) {

             $this->setUID($uid);

         }



Thus, $uid is empty! Now, back in import:

      $event->setCalendar($calendar);

      // Check if the entry already exists in the data source, first

      // by UID.

      $uid = $event->getUID();

      $existing_event = &$kronolith_driver->getByUID($uid);





/horde/kronolith/lib/Driver/sql.php

     function &getByUID($uid, $getAll = false)

         $query = [snip] ' FROM ' . $this->_params['table'] . ' WHERE 
event_uid = ?';

         $values = array($uid);

         $events = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);



BUT: $uid is not set, so $values does not match amount of 
placeholders, query dies, next line not reached. This is the show 
stopper: if $uid is manually set to whatever, events get imported.


Saved Queries