Added error handling in select() and count(), so on error they will return null
This commit is contained in:
parent
a7c4ebf15d
commit
b1e824becf
1 changed files with 20 additions and 5 deletions
|
@ -427,6 +427,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'];
|
||||
|
@ -450,6 +454,10 @@ class kolab_storage_cache
|
|||
$index = $this->imap->search_once($this->folder->name, $search)->get();
|
||||
}
|
||||
|
||||
if ($index->is_error()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// fetch all messages in $index from IMAP
|
||||
$result = $uids ? $this->_fetch_uids($index, $filter['type']) : $this->_fetch($index, $filter['type']);
|
||||
|
||||
|
@ -477,8 +485,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();
|
||||
|
@ -489,6 +495,10 @@ 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']);
|
||||
}
|
||||
|
@ -497,6 +507,11 @@ class kolab_storage_cache
|
|||
$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);
|
||||
|
||||
if ($index->is_error()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$count = $index->count();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue