Summary | Kronolith syncml duplicate event detection broken |
Queue | Synchronization |
Queue Version | Git master |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org |
Requester | horde (at) albasoft (dot) com |
Created | 06/19/2015 (3707 days ago) |
Due | |
Updated | 06/24/2015 (3702 days ago) |
Assigned | 06/22/2015 (3704 days ago) |
Resolved | 06/24/2015 (3702 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | Yes |
State ⇒ Resolved
commit 261745cb674115acdd1a67d1fd48d99abd3a7365
Author: horde@albasoft.com <horde@albasoft.com>
Date: Wed Jun 24 11:06:07 2015 -0400
Bug: 14018Fix comparision.This was failing if the datetime was equal, but the timezone
identifier was different.
Signed-off-by: Michael J Rubinsky <mrubinsk@horde.org>
kronolith/lib/Api.php | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
http://github.com/horde/horde/commit/261745cb674115acdd1a67d1fd48d99abd3a7365
But my event test keeps failing, because of a timezone problem, as
more debug has shown.
I have this setting in my php.ini:
date.timezone = "Europe/Madrid"
which is a supported setting (
http://php.net/manual/en/timezones.europe.php ).
But funambol for thunderbird (Windows desktop) is sending the events
with another timezone, and if I debug that date comparison in
kronolith/lib/Api.php for both date objects, it shows this:
2015-06-22T16:38:50+02:00 WARN: HORDE Caught output:
Horde_Date Object
(
[_year:protected] => 2015
[_month:protected] => 6
[_mday:protected] => 22
[_hour:protected] => 15
[_min:protected] => 0
[_sec:protected] => 0
[_timezone:protected] => Europe/Paris
[_defaultFormat:protected] => Y-m-d H:i:s
[_formatCache:protected] => Array
(
[Y-m-d H:i:s] => 2015-06-22 15:00:00
)
)
Horde_Date Object
(
[_year:protected] => 2015
[_month:protected] => 6
[_mday:protected] => 22
[_hour:protected] => 15
[_min:protected] => 0
[_sec:protected] => 0
[_timezone:protected] => Europe/Madrid
[_defaultFormat:protected] => Y-m-d H:i:s
[_formatCache:protected] => Array
(
[Y-m-d H:i:s] => 2015-06-22 15:00:00
)
)
Timezone are different, but date are equal, as both timezones are
GMT+1 (+2 right now in summer).
Once the event has been inserted in DB, the second format is used. The
former is the new event being inserted by funambol.
Thus, comparing them with "==" return false, while using
compareDateTime function returns true.
Thanks for your time.
State ⇒ Feedback
to string using Horde_Date::__toString().
compareDateTime for it to work.
following tests work:
<code>
$d1 = new Horde_Date('2015-06-20');
$d2 = new Horde_Date('2015-06-20');
var_dump($d1 == $d2);
</code>
Results
bool(true)
=========
<code>
$d1 = new Horde_Date('2015-06-20');
$d2 = new Horde_Date('2014-06-20');
var_dump($d1 == $d2);
</code>
Results
bool(false)
objects and none is a string?
cast to string using Horde_Date::__toString().
compareDateTime for it to work.
Sure it has to be cast to string in that comparison, when both are
objects and none is a string?
State ⇒ Resolved
Assigned to Michael Rubinsky
Also, the date object comparison is fine, as it is automagically cast
to string using Horde_Date::__toString().
commit 85481894136d7ac88101e9cd265abd29bc3e9d1a
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date: Sat Jun 20 11:52:17 2015 -0400
Fix iterating search results (
Bug #14018).kronolith/lib/Api.php | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
http://github.com/horde/horde/commit/85481894136d7ac88101e9cd265abd29bc3e9d1a
commit c6b60ea5a72e33b2969853dd9a7a520334258d1b
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date: Sat Jun 20 11:52:17 2015 -0400
Fix iterating search results (
Bug #14018).kronolith/lib/Api.php | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
http://github.com/horde/horde/commit/c6b60ea5a72e33b2969853dd9a7a520334258d1b
Priority ⇒ 1. Low
State ⇒ Unconfirmed
New Attachment: hordewm5-kronolith-EventExists.patch
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Synchronization
Summary ⇒ Kronolith syncml duplicate event detection broken
Type ⇒ Bug
repeated events in kronolith_events database.
I've found that there is code that could be preventing this, but it's broken.
New events from syncml pass through "_addiCalEvent" function prior to
be inserted in database as new events. And there is a search for an
existing event match in database:
$result = $driver->search($event);
// Check if the match really is an exact match:
But $driver->search returns an array of arrays of events, indexed by
date, while this code will deal with an array of events.
A loop like "foreach ($result as $match)" will have a array of events,
not a single event. It will never get a match an the event will always
be inserted as new. In fact, search actually returns thousands of
duplicated events from my database, but new is inserted anyway.
There's also another bug in this function:
if ($match->start == $event->start &&
$match->end == $event->end &&
$match->title == $event->title &&
is incorrect, as $match->start is a date object. Should be something like:
if ($match->start->compareDateTime($event->start) == 0 &&
$match->end->compareDateTime($event->end) == 0 &&
$match->title == $event->title &&
Patch is attached to clarify.