diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php index 69e52bd92ea..7b875930a24 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data/Query/History/Cache.php @@ -46,13 +46,27 @@ public function synchronize($params = array()) { $timestamp_key = 'Kolab_History_Sync:'.$this->data->getId(); + /** + * Check if we need to do a full synchronization. If our stored 'last_sync' + * timestamp is newer than the logged 'sync' action in the history database, + * the last history update aborted for some reason. + * + * If the 'sync' action from the history database is newer, it means + * our in-memory version of the data_cache was outdated + * and already updated by another process. + */ if (isset($params['last_sync']) && ($params['last_sync'] === false || - $params['last_sync'] !== $this->history->getActionTimestamp($timestamp_key, 'sync'))) { - /** - * Ignore current changeset and do a full synchronization as we are - * out of sync - */ + $params['last_sync'] > $this->history->getActionTimestamp($timestamp_key, 'sync'))) + { + $folder_id = $this->data->getIdParameters(); + unset($folder_id['type']); + + Horde::log(sprintf('Resyncing Horde_History for Kolab: last_sync: %d, logged sync: %d, folder. %s', + $params['last_sync'], + $this->history->getActionTimestamp($timestamp_key, 'sync'), + print_r($folder_id, true)), 'WARN'); + unset($params['changes']); } // Sync. Base class takes care of UIDVALIDITY changes.