From b6e24c6946606cd504d522451c36b6dc574fe75d Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 16 Jan 2014 05:33:57 -0500
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 db94e76..0cf34b2 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -969,7 +969,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);
             }
 
@@ -1476,10 +1476,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