From 002d1a44e4065b89602dd293551d59c66845fd52 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 11 Aug 2012 13:53:39 -0400
Subject: [PATCH] Fix wrong search result on servers without SORT support

---
 program/include/rcube_imap.php |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 2052789..6b8cc29 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1015,8 +1015,8 @@
                 $a_msg_headers, $this->sort_field, $this->sort_order);
 
             // only return the requested part of the set
-            $a_msg_headers = array_slice(array_values($a_msg_headers),
-                $from, min($cnt-$to, $this->page_size));
+            $slice_length  = min($this->page_size, $cnt - ($to > $cnt ? $from : $to));
+            $a_msg_headers = array_slice(array_values($a_msg_headers), $from, $slice_length);
 
             if ($slice) {
                 $a_msg_headers = array_slice($a_msg_headers, -$slice, $slice);

--
Gitblit v1.9.1