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 |
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.
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
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.
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
State ⇒ Feedback
Priority ⇒ 2. Medium
And we don't retrieve this event's uid properly. Right?
Priority ⇒ 3. High
State ⇒ Unconfirmed
Queue ⇒ Kronolith
Summary ⇒ Import of events via sync fails caused by empty uid
Type ⇒ Bug
$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.