Thomas Bruederli
2014-01-20 1bbf8c48868efb87baab7ae71721f2c9ad408e65
program/lib/Roundcube/rcube_imap.php
@@ -952,7 +952,8 @@
            $search_set = $this->search_set;
            $this->sort_field = null;
            $this->page_size = 100;  // limit to 100 messages per folder
            $this->page_size = 1000;  // fetch up to 1000 matching messages per folder
            $this->threading = false;
            $a_msg_headers = array();
            foreach ($search_set->sets as $resultset) {
@@ -969,9 +970,12 @@
            $to    = $from + $page_size;
            // sort headers
            if (!$this->threading) {
                $a_msg_headers = $this->conn->sortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
            if (!$this->threading && !empty($a_msg_headers)) {
                $a_msg_headers = $this->conn->sortHeaders($a_msg_headers, $sort_field, $this->sort_order);
            }
            // store (sorted) message index
            $search_set->set_message_index($a_msg_headers, $sort_field, $this->sort_order);
            // only return the requested part of the set
            $slice_length  = min($page_size, $cnt - ($to > $cnt ? $from : $to));
@@ -1279,8 +1283,13 @@
                return new rcube_result_index($folder, '* SORT');
            }
            if ($this->search_set instanceof rcube_result_multifolder) {
                $index = $this->search_set;
                $index->folder = $folder;
                // TODO: handle changed sorting
            }
            // search result is an index with the same sorting?
            if (($this->search_set instanceof rcube_result_index)
            else if (($this->search_set instanceof rcube_result_index)
                && ((!$this->sort_field && !$this->search_sorted) ||
                    ($this->search_sorted && $this->search_sort_field == $this->sort_field))
            ) {
@@ -1476,10 +1485,11 @@
            new rcube_result_index; // trigger autoloader and make these classes available for threaded context
            new rcube_result_thread;
            // connect IMAP
            if (!defined('PTHREADS_INHERIT_ALL')) {
                $this->check_connection();
            }
            // connect IMAP to have all the required classes and settings loaded
            $this->check_connection();
            // disable threading
            $this->threading = false;
            $searcher = new rcube_imap_search($this->options, $this->conn);
            $results = $searcher->exec(
@@ -1650,6 +1660,7 @@
    public function refresh_search()
    {
        if (!empty($this->search_string)) {
            // FIXME: make this work with saved multi-folder searches
            $this->search('', $this->search_string, $this->search_charset, $this->search_sort_field);
        }
@@ -1670,6 +1681,11 @@
    {
        if (!strlen($folder)) {
            $folder = $this->folder;
        }
        // decode combined UID-folder identifier
        if (preg_match('/^\d+-[^,]+$/', $uid)) {
            list($uid, $folder) = explode('-', $uid);
        }
        // get cached headers
@@ -1703,6 +1719,11 @@
            $folder = $this->folder;
        }
        // decode combined UID-folder identifier
        if (preg_match('/^\d+-[^,]+$/', $uid)) {
            list($uid, $folder) = explode('-', $uid);
        }
        // Check internal cache
        if (!empty($this->icache['message'])) {
            if (($headers = $this->icache['message']) && $headers->uid == $uid) {