From e2e745fb4ee52b11063a1654663c018084584586 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 15 Nov 2008 09:29:45 -0500
Subject: [PATCH] - don't use SORT when SEARCH is better (sort field not specified)
---
program/include/rcube_imap.php | 3 +--
program/lib/imap.inc | 17 +++++++++--------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 0eb9f7b..3fe651d 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -984,9 +984,8 @@
*/
function _search_index($mailbox, $criteria='ALL', $charset=NULL, $sort_field=NULL)
{
- if ($this->get_capability('sort'))
+ if ($sort_field && $this->get_capability('sort'))
{
- $sort_field = $sort_field ? $sort_field : $this->sort_field;
$charset = $charset ? $charset : $this->default_charset;
$a_messages = iil_C_Sort($this->conn, $mailbox, $sort_field, $criteria, FALSE, $charset);
}
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 8704e78..fb971db 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -902,10 +902,7 @@
function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE,
$encoding = 'US-ASCII') {
- /* Do "SELECT" command */
- if (!iil_C_Select($conn, $mailbox)) {
- return false;
- }
+
$field = strtoupper($field);
if ($field == 'INTERNALDATE') {
$field = 'ARRIVAL';
@@ -917,6 +914,11 @@
if (!$fields[$field]) {
return false;
}
+
+ /* Do "SELECT" command */
+ if (!iil_C_Select($conn, $mailbox)) {
+ return false;
+ }
$is_uid = $is_uid ? 'UID ' : '';
@@ -924,16 +926,15 @@
$add = " $add";
}
- $fp = $conn->fp;
$command = 's ' . $is_uid . 'SORT (' . $field . ') ';
- $command .= $encoding . ' ALL ' . $add;
+ $command .= $encoding . ' ALL' . $add;
$line = $data = '';
- if (!iil_PutLineC($fp, $command)) {
+ if (!iil_PutLineC($conn->fp, $command)) {
return false;
}
do {
- $line = chop(iil_ReadLine($fp, 1024));
+ $line = chop(iil_ReadLine($conn->fp, 1024));
if (iil_StartsWith($line, '* SORT')) {
$data .= ($data ? ' ' : '') . substr($line, 7);
} else if (preg_match('/^[0-9 ]+$/', $line)) {
--
Gitblit v1.9.1