lib/kolab_sync_backend.php

Aleksander Machniak machniak at kolabsys.com
Tue Aug 26 08:23:00 CEST 2014


 lib/kolab_sync_backend.php |   25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

New commits:
commit 3b01dbdc119d3f85c412e648c4c7b0db4ea10706
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue Aug 26 08:22:10 2014 +0200

    Performance improvement in modseq_get() (related to last commit)

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']);




More information about the commits mailing list