From 010a350715f1a36eab666fe26d3118ed025133c1 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 15 Oct 2013 05:44:34 -0400
Subject: [PATCH] Minor improvements to threaded searching

---
 program/lib/Roundcube/rcube_imap.php |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 98c8f7a..ff88bdc 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -934,7 +934,7 @@
             $to    = $from + $page_size;
 
             // sort headers
-            if (!$this->threading) {
+            if (!$this->threading && !empty($a_msg_headers)) {
                 $a_msg_headers = $this->conn->sortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
             }
 
@@ -1441,10 +1441,8 @@
             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();
 
             $searcher = new rcube_imap_search($this->options, $this->conn);
             $results = $searcher->exec(

--
Gitblit v1.9.1