From f4e6cc539699f68ea669d182e15aac65f53511cf Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 27 Apr 2010 09:41:50 -0400 Subject: [PATCH] Pass an ending timestamp when checking for server changes. This prevents a race condition in the unlikely event that an object is changed on ther server in the time between getting the time for the current sync and checking for server changes. --- .../lib/Horde/ActiveSync/Driver/Horde.php | 26 ++++++++-------- .../ActiveSync/Driver/Horde/Connector/Registry.php | 36 ++++++++++++---------- .../lib/Horde/ActiveSync/State/History.php | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde.php b/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde.php index edaefe6c0..af1596a83 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde.php @@ -250,17 +250,15 @@ class Horde_ActiveSync_Driver_Horde extends Horde_ActiveSync_Driver_Base * Get a list of server changes that occured during the specified time * period. * - * @param string $folderId The server id of the collection to check. - * @param timestamp $from_ts The starting timestamp - * @param timestamp $to_ts The ending timestamp + * @param string $folderId The server id of the collection to check. + * @param integer $from_ts The starting timestamp + * @param integer $to_ts The ending timestamp * * @return array A list of messge uids that have chnaged in the specified * time period. */ public function getServerChanges($folderId, $from_ts, $to_ts, $cutoffdate) { - // FIXME: Need to filter the results by $from_ts OR need to fix - // Horde_History to query for a timerange instead of a single timestamp $this->_logger->debug("Horde_ActiveSync_Driver_Horde::getServerChanges($folderId, $from_ts, $to_ts, $cutoffdate)"); switch ($folderId) { case self::APPOINTMENTS_FOLDER: @@ -276,9 +274,9 @@ class Horde_ActiveSync_Driver_Horde extends Horde_ActiveSync_Driver_Base } $edits = $deletes = array(); } else { - $adds = $this->_connector->calendar_listBy('add', $from_ts); - $edits = $this->_connector->calendar_listBy('modify', $from_ts); - $deletes = $this->_connector->calendar_listBy('delete', $from_ts); + $adds = $this->_connector->calendar_listBy('add', $from_ts, $to_ts); + $edits = $this->_connector->calendar_listBy('modify', $from_ts, $to_ts); + $deletes = $this->_connector->calendar_listBy('delete', $from_ts, $to_ts); } break; case self::CONTACTS_FOLDER: @@ -287,9 +285,9 @@ class Horde_ActiveSync_Driver_Horde extends Horde_ActiveSync_Driver_Base $adds = $this->_connector->contacts_list(); $edits = $deletes = array(); } else { - $adds = $this->_connector->contacts_listBy('add', $from_ts); - $edits = $this->_connector->contacts_listBy('modify', $from_ts); - $deletes = $this->_connector->contacts_listBy('delete', $from_ts); + $adds = $this->_connector->contacts_listBy('add', $from_ts, $to_ts); + $edits = $this->_connector->contacts_listBy('modify', $from_ts, $to_ts); + $deletes = $this->_connector->contacts_listBy('delete', $from_ts, $to_ts); } break; case self::TASKS_FOLDER: @@ -298,9 +296,9 @@ class Horde_ActiveSync_Driver_Horde extends Horde_ActiveSync_Driver_Base $adds = $this->_connector->tasks_listTasks(); $edits = $deletes = array(); } else { - $adds = $this->_connector->tasks_listBy('add', $from_ts); - $edits = $this->_connector->tasks_listBy('modify', $from_ts); - $deletes = $this->_connector->tasks_listBy('delete', $from_ts); + $adds = $this->_connector->tasks_listBy('add', $from_ts, $to_ts); + $edits = $this->_connector->tasks_listBy('modify', $from_ts, $to_ts); + $deletes = $this->_connector->tasks_listBy('delete', $from_ts, $to_ts); } break; } diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde/Connector/Registry.php b/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde/Connector/Registry.php index c06430f58..0b4b44028 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde/Connector/Registry.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Driver/Horde/Connector/Registry.php @@ -42,8 +42,8 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry /** * Get a list of events from horde's calendar api * - * @param timestamp $startstamp The start of time period. - * @param timestamp $endstamp The end of time period + * @param integer $startstamp The start of time period. + * @param integer $endstamp The end of time period * * @return array */ @@ -64,14 +64,15 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry /** * Get a list of event uids that have had $action happen since $from_ts. * - * @param string $action The action to check for (add, modify, delete) - * @param timestamp $from_ts The timestamp to start checking from + * @param string $action The action to check for (add, modify, delete) + * @param integer $from_ts The timestamp to start checking from + * @param integer $to_ts The ending timestamp * * @return array An array of event uids */ - public function calendar_listBy($action, $from_ts) + public function calendar_listBy($action, $from_ts, $to_ts) { - return $this->_registry->calendar->listBy($action, (int)$from_ts); + return $this->_registry->calendar->listBy($action, $from_ts, null, $to_ts); } /** @@ -130,7 +131,7 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry * @param string $uid The UID of the event we are interested in. * @param string $action The action we are interested in (add, modify...) * - * @return timestamp + * @return integer */ public function calendar_getActionTimestamp($uid, $action) { @@ -205,7 +206,7 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry * @param string $uid The UID of the contact to search * @param string $action The action to lookup * - * @return timestamp + * @return integer */ public function contacts_getActionTimestamp($uid, $action) { @@ -215,14 +216,14 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry /** * Get a list of contact uids that have had $action happen since $from_ts. * - * @param string $action The action to check for (add, modify, delete) - * @param timestamp $from_ts The timestamp to start checking from - * + * @param string $action The action to check for (add, modify, delete) + * @param integer $from_ts The timestamp to start checking from + * @param integer $to_ts The ending timestamp * @return array An array of event uids */ - public function contacts_listBy($action, $from_ts) + public function contacts_listBy($action, $from_ts, $to_ts) { - return $this->_registry->contacts->listBy($action, (int)$from_ts); + return $this->_registry->contacts->listBy($action, $from_ts, null, $to_ts); } /** @@ -297,7 +298,7 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry * @param string $uid The UID of the task we are interested in. * @param string $action The action we are interested in (add, modify...) * - * @return timestamp + * @return integer */ public function tasks_getActionTimestamp($uid, $action) { @@ -307,14 +308,15 @@ class Horde_ActiveSync_Driver_Horde_Connector_Registry /** * Get a list of task uids that have had $action happen since $from_ts. * - * @param string $action The action to check for (add, modify, delete) - * @param timestamp $from_ts The timestamp to start checking from + * @param string $action The action to check for (add, modify, delete) + * @param integer $from_ts The timestamp to start checking from + * @param integer $to_ts The ending timestamp * * @return array An array of event uids */ public function tasks_listBy($action, $from_ts) { - return $this->_registry->tasks->listBy($action, (int)$from_ts); + return $this->_registry->tasks->listBy($action, $from_ts, null, $to_ts); } /** diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php index adfbbaced..867443f0a 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php @@ -665,7 +665,7 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base } /* No existing changes, poll the backend */ - $changes = $this->_backend->getServerChanges($folderId, $this->_lastSyncTS, $this->_thisSyncTS, $cutoffdate); + $changes = $this->_backend->getServerChanges($folderId, (int)$this->_lastSyncTS, (int)$this->_thisSyncTS, $cutoffdate); } /* Unfortunately we can't use an empty synckey to detect an initial * sync. The AS protocol doesn't start looking for changes until -- 2.11.0