From f255dd787c62b4910a5794ff1379cad80781e311 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 22 Jun 2013 08:46:10 +0200 Subject: Fix error when searching in threaded mode --- program/lib/Roundcube/rcube_imap.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'program/lib/Roundcube/rcube_imap.php') diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index d65f6afab..5a80779cd 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -1206,29 +1206,33 @@ class rcube_imap extends rcube_storage // we have a saved search result, get index from there if ($this->search_string) { - if ($this->search_threads) { - $this->search($folder, $this->search_string, $this->search_charset, $this->sort_field); + if ($this->search_set->is_empty()) { + return new rcube_result_index(); } - // use message index sort as default sorting - if (!$this->sort_field || $this->search_sorted) { - if ($this->sort_field && $this->search_sort_field != $this->sort_field) { - $this->search($folder, $this->search_string, $this->search_charset, $this->sort_field); - } - $index = $this->search_set; + // disable threading temporarily + $threading = $this->threading; + $this->threading = false; + + if ($this->search_threads) { + $index = $this->search_index($folder, $this->search_string, $this->search_charset, $this->sort_field); } - else if (!$this->check_connection()) { - return new rcube_result_index(); + else if ((!$this->sort_field && !$this->search_sorted) || + ($this->search_sorted && $this->search_sort_field == $this->sort_field) + ) { + $index = $this->search_set; } else { - $index = $this->conn->index($folder, $this->search_set->get(), - $this->sort_field, $this->options['skip_deleted'], true, true); + $search = 'UID ' . $this->search_set->get_compressed(); + $index = $this->search_index($folder, $search, $this->search_charset, $this->sort_field); } if ($this->sort_order != $index->get_parameters('ORDER')) { $index->revert(); } + $this->threading = $threading; + return $index; } -- cgit v1.2.3