summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-08-26 06:22:10 (GMT)
committerAleksander Machniak <alec@alec.pl>2014-08-26 06:22:10 (GMT)
commit3b01dbdc119d3f85c412e648c4c7b0db4ea10706 (patch)
treebce53c4debe1dea1a59b58c2103b89f129ddb70a
parentbde4a2325ca38726a47e7c9069505df8e1a15e95 (diff)
downloadkolab-syncroton-3b01dbdc119d3f85c412e648c4c7b0db4ea10706.tar.gz
Performance improvement in modseq_get() (related to last commit)
-rw-r--r--lib/kolab_sync_backend.php25
1 files changed, 7 insertions, 18 deletions
diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index b1ccc4e..e288530 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -840,28 +840,17 @@ class kolab_sync_backend
$synctime = $synctime->format('Y-m-d H:i:s');
if (empty($this->modseq[$folderid][$synctime])) {
+ $this->modseq[$folderid] = array();
+
$rcube = rcube::get_instance();
$db = $rcube->get_dbh();
- $db->query("SELECT data, synctime FROM syncroton_modseq"
- ." WHERE device_id = ? AND folder_id = ? AND synctime = ?",
- $deviceid, $folderid, $synctime);
-
- $row = $db->fetch_assoc();
-
- // record doesn't exist, get previous one
- if (!$row) {
- $db->limitquery("SELECT data, synctime FROM syncroton_modseq"
- ." WHERE device_id = ? AND folder_id = ? AND synctime < ?"
- ." ORDER BY synctime DESC",
- 0, 1, $deviceid, $folderid, $synctime);
-
- $row = $db->fetch_assoc();
- }
-
- $this->modseq[$folderid] = array();
+ $db->limitquery("SELECT data, synctime FROM syncroton_modseq"
+ ." WHERE device_id = ? AND folder_id = ? AND synctime <= ?"
+ ." ORDER BY synctime DESC",
+ 0, 1, $deviceid, $folderid, $synctime);
- if ($row) {
+ if ($row = $db->fetch_assoc()) {
$synctime = $row['synctime'];
// @TODO: make sure synctime from sql is in "Y-m-d H:i:s" format
$this->modseq[$folderid][$synctime] = json_decode($row['data']);