docs/SQL lib/kolab_sync_backend.php

Aleksander Machniak machniak at kolabsys.com
Mon Aug 25 14:19:57 CEST 2014


 docs/SQL/mysql.initial.sql    |    2 +-
 docs/SQL/mysql/2014082500.sql |    1 +
 lib/kolab_sync_backend.php    |    8 ++++----
 3 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 813c7becb7f561e5af6c5ed2641703bf66235059
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Aug 25 14:19:21 2014 +0200

    Change syncroton_modseq.synctime column type to datetime

diff --git a/docs/SQL/mysql.initial.sql b/docs/SQL/mysql.initial.sql
index 750d514..71106b9 100644
--- a/docs/SQL/mysql.initial.sql
+++ b/docs/SQL/mysql.initial.sql
@@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS `syncroton_data_folder` (
 CREATE TABLE IF NOT EXISTS `syncroton_modseq` (
     `device_id` varchar(40) NOT NULL,
     `folder_id` varchar(40) NOT NULL,
-    `synctime` varchar(14) NOT NULL,
+    `synctime` datetime NOT NULL,
     `data` longblob,
     PRIMARY KEY (`device_id`,`folder_id`,`synctime`),
     KEY `syncroton_modseq::device_id` (`device_id`),
diff --git a/docs/SQL/mysql/2014082500.sql b/docs/SQL/mysql/2014082500.sql
new file mode 100644
index 0000000..80309e4
--- /dev/null
+++ b/docs/SQL/mysql/2014082500.sql
@@ -0,0 +1 @@
+ALTER TABLE `syncroton_modseq` CHANGE `synctime` `synctime` datetime DEFAULT NULL;
diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index 3fbf6cb..363351e 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -818,7 +818,7 @@ class kolab_sync_backend
      */
     public function modseq_set($deviceid, $folderid, $synctime, $data)
     {
-        $synctime = $synctime->format('Ymdhis');
+        $synctime = $synctime->format('Y-m-d h:i:s');
         $rcube    = rcube::get_instance();
         $db       = $rcube->get_dbh();
 
@@ -840,7 +840,7 @@ class kolab_sync_backend
 
     public function modseq_get($deviceid, $folderid, $synctime)
     {
-        $synctime = $synctime->format('Ymdhis');
+        $synctime = $synctime->format('Y-m-d h:i:s');
 
         if (!isset($this->modseq[$deviceid]) || !isset($this->modseq[$deviceid][$folderid])
             || !isset($this->modseq[$deviceid][$folderid][$synctime])
@@ -854,8 +854,8 @@ class kolab_sync_backend
                 0, 2, $deviceid, $folderid, $synctime);
 
             if ($row = $db->fetch_assoc()) {
-                $current = $row['synctime'];
-                $this->modseq[$deviceid][$folderid][$synctime] = json_decode($row['data']);
+                // @TODO: make sure synctime from sql is in "Y-m-d h:i:s" format
+                $this->modseq[$deviceid][$folderid][$row['synctime']] = json_decode($row['data']);
 
                 // Cleanup: remove old records (keep last two)
                 if ($row = $db->fetch_assoc()) {




More information about the commits mailing list