From 6c25221b95f0c12b3f607c3bcc8a9bb8192ca6bb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 24 Feb 2016 13:57:58 +0100 Subject: [PATCH] Performance: Make objects moving faster (less SQL and less IMAP operations) using COPYUID --- plugins/libkolab/lib/kolab_storage_cache.php | 17 +++++++++++------ plugins/libkolab/lib/kolab_storage_folder.php | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index 8b6b0e07..41984702 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -429,18 +429,23 @@ class kolab_storage_cache /** * Move an existing cache entry to a new resource * - * @param string Entry's IMAP message UID - * @param string Entry's Object UID - * @param object kolab_storage_folder Target storage folder instance + * @param string Entry's IMAP message UID + * @param string Entry's Object UID + * @param kolab_storage_folder Target storage folder instance + * @param string Target entry's IMAP message UID */ - public function move($msguid, $uid, $target) + public function move($msguid, $uid, $target, $new_msguid = null) { - if ($this->ready) { + if ($this->ready && $target) { // clear cached uid mapping and force new lookup unset($target->cache->uid2msg[$uid]); // resolve new message UID in target folder - if ($new_msguid = $target->cache->uid2msguid($uid)) { + if (!$new_msguid) { + $new_msguid = $target->cache->uid2msguid($uid); + } + + if ($new_msguid) { $this->_read_folder_data(); $this->db->query( diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 99ea7297..00d02efc 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -930,7 +930,8 @@ class kolab_storage_folder extends kolab_storage_folder_api $this->cache->bypass(false); if ($result) { - $this->cache->move($msguid, $uid, $target_folder); + $new_uid = ($copyuid = $this->imap->conn->data['COPYUID']) ? $copyuid[1] : null; + $this->cache->move($msguid, $uid, $target_folder, $new_uid); return true; } else {