From 8fcc3e1ad67496496c788023daeb01631a39d915 Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 14 Oct 2010 10:22:25 +0000 Subject: - Improved IMAP errors handling --- program/include/rcube_imap.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'program/include/rcube_imap.php') diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 0a27989b9..9d027c87c 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -32,7 +32,6 @@ class rcube_imap { public $debug_level = 1; - public $error_code = 0; public $skip_deleted = false; public $root_dir = ''; public $page_size = 10; @@ -173,7 +172,6 @@ class rcube_imap } // write error log else if ($this->conn->error) { - $this->error_code = $this->conn->errornum; if ($pass && $user) raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__, 'line' => __LINE__, @@ -213,7 +211,29 @@ class rcube_imap $this->conn->select($this->mailbox); } + + /** + * Returns code of last error + * + * @return int Error code + */ + function get_error_code() + { + return ($this->conn) ? $this->conn->errornum : 0; + } + + + /** + * Returns message of last error + * + * @return string Error message + */ + function get_error_str() + { + return ($this->conn) ? $this->conn->error : ''; + } + /** * Set options to be used in rcube_imap_generic::connect() * @@ -568,11 +588,11 @@ class rcube_imap if (!empty($this->icache['threads'])) return count($this->icache['threads']['tree']); - list ($thread_tree, $msg_depth, $has_children) = $this->_fetch_threads($mailbox); - - $msg_count = count($msg_depth); + if (is_array($result = $this->_fetch_threads($mailbox))) + $thread_tree = array_shift($result); -// $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); +// list ($thread_tree, $msg_depth, $has_children) = $result; +// $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); return count($thread_tree); } -- cgit v1.2.3