Skip to content

Commit

Permalink
Fix sync "loop" of Kolab categories <-> Horde tags sync. Fixes #12770.
Browse files Browse the repository at this point in the history
Consider this scenario with a new, empty calendar:

1. User inserts the first event. The event is tagged with "foobar".
   This tag is inserted into the tagging backend.
2. User creates another event with a foreign Kolab client.
   This event is tagged "Foobar" (noticed the capital 'F')
3. kronolith syncs in the foreign event. The Kolab sync tells
   the tag backend to store the tag(s) for the new event object,
   it does a case insensitive search for an existing tag label.
   -> it picks the existing row id of "foobar".

The next time Event::synchronizeTags() runs, it notices
the tags given by the Kolab driver for the second event
differ from the tag backend ("Foobar" != "foobar")
    -> A sync is triggered.

I have a productive calendar with about 2.000 events.
The sync "loop" produces 3.6000+ INSERT / UPDATE statements
on every click.

Fix it by making the tag label comparison case insensitive.

Signed-off-by: Michael J Rubinsky <mrubinsk@horde.org>
  • Loading branch information
thomasjfox authored and mrubinsk committed Nov 21, 2013
1 parent f76e66f commit 24181ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kronolith/lib/Event.php
Expand Up @@ -2515,8 +2515,10 @@ public function isAllDay()
public function synchronizeTags($tags)
{
if (isset($this->_internaltags)) {
usort($tags, 'strcoll');
if (array_diff($this->_internaltags, $tags)) {
$lower_internaltags = array_map('Horde_String::lower', $this->_internaltags);
$lower_tags = array_map('Horde_String::lower', $tags);

if (array_diff($lower_internaltags, $lower_tags)) {
Kronolith::getTagger()->replaceTags(
$this->uid,
$this->_internaltags,
Expand Down

0 comments on commit 24181ad

Please sign in to comment.