Branch 'roundcubemail-plugins-kolab-3.1' - plugins/libkolab
Aleksander Machniak
machniak at kolabsys.com
Thu Jan 2 13:38:52 CET 2014
plugins/libkolab/lib/kolab_storage_cache.php | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
New commits:
commit 57f1955fb8adb965583c3564f14ded36db839e3a
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Thu Jan 2 13:37:39 2014 +0100
Added error handling in select() and count(), so on error they will return null
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index bff69ea..db174e5 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -419,6 +419,10 @@ class kolab_storage_cache
$this->folder_id
);
+ if ($this->db->is_error($sql_result)) {
+ return null;
+ }
+
while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
if ($uids) {
$this->uid2msg[$sql_arr['uid']] = $sql_arr['msguid'];
@@ -439,7 +443,11 @@ class kolab_storage_cache
}
else { // search by object type
$search = 'UNDELETED HEADER X-Kolab-Type ' . kolab_format::KTYPE_PREFIX . $filter['type'];
- $index = $this->imap->search_once($this->folder->name, $search)->get();
+ $index = $this->imap->search_once($this->folder->name, $search)->get();
+ }
+
+ if ($index->is_error()) {
+ return null;
}
// fetch all messages in $index from IMAP
@@ -469,8 +477,6 @@ class kolab_storage_cache
*/
public function count($query = array())
{
- $count = 0;
-
// cache is in sync, we can count records in local DB
if ($this->synched) {
$this->_read_folder_data();
@@ -481,14 +487,23 @@ class kolab_storage_cache
$this->folder_id
);
+ if ($this->db->is_error($sql_result)) {
+ return null;
+ }
+
$sql_arr = $this->db->fetch_assoc($sql_result);
- $count = intval($sql_arr['numrows']);
+ $count = intval($sql_arr['numrows']);
}
else {
// search IMAP by object type
$filter = $this->_query2assoc($query);
$ctype = kolab_format::KTYPE_PREFIX . $filter['type'];
- $index = $this->imap->search_once($this->folder->name, 'UNDELETED HEADER X-Kolab-Type ' . $ctype);
+ $index = $this->imap->search_once($this->folder->name, 'UNDELETED HEADER X-Kolab-Type ' . $ctype);
+
+ if ($index->is_error()) {
+ return null;
+ }
+
$count = $index->count();
}
More information about the commits
mailing list