- performance improvement: skip SEARCH command when mailbox is empty and SEARCH is called just after SELECT
| | |
| | | $search_str .= " UNSEEN"; |
| | | // get message count using SEARCH |
| | | // not very performant but more precise (using UNDELETED) |
| | | // disable THREADS for this request |
| | | $threads = $this->threading; |
| | | $this->threading = false; |
| | | $index = $this->_search_index($mailbox, $search_str); |
| | | $this->threading = $threads; |
| | | $index = $this->conn->search($mailbox, $search_str); |
| | | |
| | | $count = is_array($index) ? count($index) : 0; |
| | | |
| | |
| | | |
| | | function search($folder, $criteria, $return_uid=false) |
| | | { |
| | | $old_sel = $this->selected; |
| | | |
| | | if (!$this->select($folder)) { |
| | | return false; |
| | | } |
| | | |
| | | // return empty result when folder is empty and we're just after SELECT |
| | | if ($old_sel != $folder && !$this->exists) { |
| | | return array(); |
| | | } |
| | | |
| | | $data = ''; |
| | | $query = 'srch1 ' . ($return_uid ? 'UID ' : '') . 'SEARCH ' . chop($criteria); |
| | | |