From 31aa080609f6ea8a561182eb5b3da46733bef313 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 23 Apr 2014 07:21:51 -0400
Subject: [PATCH] Further refine cross-folder searching: - Store incomplete search results in session and re-send search requests   to the server if returned before complete (this should avoid hitting request timeouts). - Display full folder path on mouseover in message list - Remove pthreads implementation stuff as this wasn't really working

---
 program/steps/mail/search.inc |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 813e8c4..f52d1a0 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -38,6 +38,7 @@
 $filter  = rcube_utils::get_input_value('_filter', rcube_utils::INPUT_GET);
 $headers = rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET);
 $scope   = rcube_utils::get_input_value('_scope', rcube_utils::INPUT_GET);
+$continue = rcube_utils::get_input_value('_continue', rcube_utils::INPUT_GET);
 $subject = array();
 
 $filter         = trim($filter);
@@ -110,6 +111,12 @@
 $search_str  = trim($search_str);
 $sort_column = rcmail_sort_column();
 
+// set message set for already stored (but incomplete) search request
+if (!empty($continue) && isset($_SESSION['search']) && $_SESSION['search_request'] == $continue) {
+    $RCMAIL->storage->set_search_set($_SESSION['search']);
+    $search_str = $_SESSION['search'][0];
+}
+
 // execute IMAP search
 if ($search_str) {
     // search all, current or subfolders folders
@@ -126,10 +133,6 @@
     $result = $RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column);
 }
 
-// Get the headers
-$result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order());
-$count    = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
-
 // save search results in session
 if (!is_array($_SESSION['search'])) {
     $_SESSION['search'] = array();
@@ -141,6 +144,13 @@
 }
 $_SESSION['search_request'] = $search_request;
 $_SESSION['search_scope'] = $scope;
+
+
+// Get the headers
+if (!$result->incomplete) {
+    $result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order());
+    $count    = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
+}
 
 // Make sure we got the headers
 if (!empty($result_h)) {
@@ -157,9 +167,15 @@
     }
 }
 // handle IMAP errors (e.g. #1486905)
-else  if ($err_code = $RCMAIL->storage->get_error_code()) {
+else if ($err_code = $RCMAIL->storage->get_error_code()) {
     $RCMAIL->display_server_error();
 }
+// advice the client to re-send the (cross-folder) search request
+else if ($result->incomplete) {
+    $count = 0;  // keep UI locked
+    $OUTPUT->command('continue_search', $search_request);
+    console('search incomplete', strlen(serialize($result)));
+}
 else {
     $OUTPUT->show_message('searchnomatch', 'notice');
     $OUTPUT->set_env('multifolder_listing', (bool)$result->multi);

--
Gitblit v1.9.1