4 commits - plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Jun 27 10:52:19 CEST 2012
plugins/libkolab/lib/kolab_format_contact.php | 2
plugins/libkolab/lib/kolab_format_distributionlist.php | 2
plugins/libkolab/lib/kolab_format_journal.php | 2
plugins/libkolab/lib/kolab_format_note.php | 2
plugins/libkolab/lib/kolab_format_xcal.php | 2
plugins/libkolab/lib/kolab_storage.php | 4
plugins/libkolab/lib/kolab_storage_cache.php | 79 ++++++++++-------
plugins/libkolab/lib/kolab_storage_folder.php | 2
8 files changed, 62 insertions(+), 33 deletions(-)
New commits:
commit 8961bf3147116a3725728306c11f7d045784cbda
Merge: 290d0f1 fbcf125
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Wed Jun 27 10:52:40 2012 +0200
Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube
commit 290d0f113fac34cb706594d015cf2ac071855393
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue Jun 26 16:54:04 2012 +0200
Use explicit insert() method to skip delete query when caching a newly created object (updated objects get new msguids and are de-facto new)
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 004776e..a361eb4 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -202,50 +202,67 @@ class kolab_storage_cache
return;
}
- // write to cache
+ // remove old entry
if ($this->ready) {
- // remove old entry
$this->db->query("DELETE FROM kolab_cache WHERE resource=? AND msguid=? AND type<>?",
$this->resource_uri, $msguid, 'lock');
+ }
- // write new object data if not false (wich means deleted)
- if ($object) {
- $sql_data = $this->_serialize($object);
- $objtype = $object['_type'] ? $object['_type'] : $this->folder->type;
+ if ($object) {
+ // insert new object data...
+ $this->insert($msguid, $object);
+ }
+ else {
+ // ...or set in-memory cache to false
+ $this->objects[$msguid] = $object;
+ }
+ }
- $result = $this->db->query(
- "INSERT INTO kolab_cache ".
- " (resource, type, msguid, uid, created, changed, data, xml, dtstart, dtend, tags, words)".
- " VALUES (?, ?, ?, ?, " . $this->db->now() . ", ?, ?, ?, ?, ?, ?, ?)",
- $this->resource_uri,
- $objtype,
- $msguid,
- $object['uid'],
- $sql_data['changed'],
- $sql_data['data'],
- $sql_data['xml'],
- $sql_data['dtstart'],
- $sql_data['dtend'],
- $sql_data['tags'],
- $sql_data['words']
- );
- if (!$this->db->affected_rows($result)) {
- rcube::raise_error(array(
- 'code' => 900, 'type' => 'php',
- 'message' => "Failed to write to kolab cache"
- ), true);
- }
+ /**
+ * Insert a cache entry
+ *
+ * @param string Related IMAP message UID
+ * @param mixed Hash array with object properties to save or false to delete the cache entry
+ */
+ public function insert($msguid, $object)
+ {
+ // write to cache
+ if ($this->ready) {
+ $sql_data = $this->_serialize($object);
+ $objtype = $object['_type'] ? $object['_type'] : $this->folder->type;
+
+ $result = $this->db->query(
+ "INSERT INTO kolab_cache ".
+ " (resource, type, msguid, uid, created, changed, data, xml, dtstart, dtend, tags, words)".
+ " VALUES (?, ?, ?, ?, " . $this->db->now() . ", ?, ?, ?, ?, ?, ?, ?)",
+ $this->resource_uri,
+ $objtype,
+ $msguid,
+ $object['uid'],
+ $sql_data['changed'],
+ $sql_data['data'],
+ $sql_data['xml'],
+ $sql_data['dtstart'],
+ $sql_data['dtend'],
+ $sql_data['tags'],
+ $sql_data['words']
+ );
+
+ if (!$this->db->affected_rows($result)) {
+ rcube::raise_error(array(
+ 'code' => 900, 'type' => 'php',
+ 'message' => "Failed to write to kolab cache"
+ ), true);
}
}
// keep a copy in memory for fast access
$this->objects[$msguid] = $object;
-
- if ($object)
- $this->uid2msg[$object['uid']] = $msguid;
+ $this->uid2msg[$object['uid']] = $msguid;
}
+
/**
* Move an existing cache entry to a new resource
*
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index aaaceca..421531a 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -592,7 +592,7 @@ class kolab_storage_folder
// update cache with new UID
if ($result) {
$object['_msguid'] = $result;
- $this->cache->set($result, $object);
+ $this->cache->insert($result, $object);
}
}
commit 5fa593ad9952fe2d660188006afb5402ae871109
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue Jun 26 16:50:17 2012 +0200
Clear cache before deleting a Kolab folder
diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php
index 760cd07..7eafd9b 100644
--- a/plugins/libkolab/lib/kolab_storage.php
+++ b/plugins/libkolab/lib/kolab_storage.php
@@ -164,7 +164,9 @@ class kolab_storage
*/
public static function folder_delete($name)
{
- self::setup();
+ // clear cached entries first
+ if ($folder = self::get_folder($name))
+ $folder->cache->purge();
$success = self::$imap->delete_folder($name);
self::$last_error = self::$imap->get_error_str();
commit af2bf9005cda307c586cc630d68791db1a5cad5d
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue Jun 26 16:31:42 2012 +0200
Update changed property when updating a Kolab object
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 84df742..6781342 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -135,6 +135,8 @@ class kolab_format_contact extends kolab_format
if (!empty($object['uid']))
$this->obj->setUid($object['uid']);
+ $object['changed'] = new DateTime('now', self::$timezone);
+
// do the hard work of setting object values
$nc = new NameComponents;
$nc->setSurnames(self::array2vector($object['surname']));
diff --git a/plugins/libkolab/lib/kolab_format_distributionlist.php b/plugins/libkolab/lib/kolab_format_distributionlist.php
index e8fae76..fe99804 100644
--- a/plugins/libkolab/lib/kolab_format_distributionlist.php
+++ b/plugins/libkolab/lib/kolab_format_distributionlist.php
@@ -49,6 +49,8 @@ class kolab_format_distributionlist extends kolab_format
if (!empty($object['uid']))
$this->obj->setUid($object['uid']);
+ $object['changed'] = new DateTime('now', self::$timezone);
+
$this->obj->setName($object['name']);
$seen = array();
diff --git a/plugins/libkolab/lib/kolab_format_journal.php b/plugins/libkolab/lib/kolab_format_journal.php
index 46a59db..219c6f1 100644
--- a/plugins/libkolab/lib/kolab_format_journal.php
+++ b/plugins/libkolab/lib/kolab_format_journal.php
@@ -49,6 +49,8 @@ class kolab_format_journal extends kolab_format
if (!empty($object['uid']))
$this->obj->setUid($object['uid']);
+ $object['changed'] = new DateTime('now', self::$timezone);
+
// TODO: set object propeties
// cache this data
diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php
index 1eafa72..a5b2cd4 100644
--- a/plugins/libkolab/lib/kolab_format_note.php
+++ b/plugins/libkolab/lib/kolab_format_note.php
@@ -49,6 +49,8 @@ class kolab_format_note extends kolab_format
if (!empty($object['uid']))
$this->obj->setUid($object['uid']);
+ $object['changed'] = new DateTime('now', self::$timezone);
+
// TODO: set object propeties
// cache this data
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index db2ad3a..18cf6e5 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -221,6 +221,8 @@ abstract class kolab_format_xcal extends kolab_format
if (!empty($object['uid']))
$this->obj->setUid($object['uid']);
+ $object['changed'] = new DateTime('now', self::$timezone);
+
// increment sequence
$this->obj->setSequence($this->obj->sequence()+1);
More information about the commits
mailing list