From 70a8236cd5db7f1dee55dc9da8ee7bc49a1bf813 Mon Sep 17 00:00:00 2001 From: Bostjan Skufca <bostjan@a2o.si> Date: Sat, 09 Apr 2016 09:20:28 -0400 Subject: [PATCH] mailbox/listing: Make server response for large mailbox listing faster when using threaded view --- program/lib/Roundcube/rcube_result_thread.php | 51 ++++++++++----------------------------------------- 1 files changed, 10 insertions(+), 41 deletions(-) diff --git a/program/lib/Roundcube/rcube_result_thread.php b/program/lib/Roundcube/rcube_result_thread.php index ceaaf59..b80e38b 100644 --- a/program/lib/Roundcube/rcube_result_thread.php +++ b/program/lib/Roundcube/rcube_result_thread.php @@ -1,6 +1,6 @@ <?php -/* +/** +-----------------------------------------------------------------------+ | This file is part of the Roundcube Webmail client | | Copyright (C) 2005-2011, The Roundcube Dev Team | @@ -26,6 +26,8 @@ */ class rcube_result_thread { + public $incomplete = false; + protected $raw_data; protected $mailbox; protected $meta = array(); @@ -44,7 +46,6 @@ $this->mailbox = $mailbox; $this->init($data); } - /** * Initializes object with IMAP command response @@ -81,7 +82,6 @@ $this->raw_data = $this->parse_thread($data); } - /** * Checks the result from IMAP command * @@ -89,9 +89,8 @@ */ public function is_error() { - return $this->raw_data === null ? true : false; + return $this->raw_data === null; } - /** * Checks if the result is empty @@ -100,9 +99,8 @@ */ public function is_empty() { - return empty($this->raw_data) ? true : false; + return empty($this->raw_data); } - /** * Returns number of elements (threads) in the result @@ -126,7 +124,6 @@ return $this->meta['count']; } - /** * Returns number of all messages in the result @@ -153,7 +150,6 @@ return $this->meta['messages']; } - /** * Returns maximum message identifier in the result * @@ -167,7 +163,6 @@ return $this->meta['max']; } - /** * Returns minimum message identifier in the result * @@ -180,7 +175,6 @@ } return $this->meta['min']; } - /** * Slices data set. @@ -197,7 +191,6 @@ $this->meta['count'] = count($data); $this->raw_data = implode(self::SEPARATOR_ELEMENT, $data); } - /** * Filters data set. Removes threads not listed in $roots list. @@ -238,7 +231,6 @@ $this->raw_data = ltrim($result, self::SEPARATOR_ELEMENT); } - /** * Reverts order of elements in the result */ @@ -250,24 +242,11 @@ return; } + $raw_data_reverse = implode(self::SEPARATOR_ELEMENT, array_reverse(explode(self::SEPARATOR_ELEMENT, $this->raw_data))); + $this->raw_data = $raw_data_reverse; + $this->meta['pos'] = array(); - $datalen = strlen($this->raw_data); - $result = ''; - $start = 0; - - while (($pos = @strpos($this->raw_data, self::SEPARATOR_ELEMENT, $start)) - || ($start < $datalen && ($pos = $datalen)) - ) { - $len = $pos - $start; - $elem = substr($this->raw_data, $start, $len); - $start = $pos + 1; - - $result = $elem . self::SEPARATOR_ELEMENT . $result; - } - - $this->raw_data = rtrim($result, self::SEPARATOR_ELEMENT); } - /** * Check if the given message ID exists in the object @@ -312,7 +291,6 @@ return false; } - /** * Return IDs of all messages in the result. Threaded data will be flattened. * @@ -331,7 +309,6 @@ return preg_split($regexp, $this->raw_data); } - /** * Return all messages in the result. * @@ -345,7 +322,6 @@ return rcube_imap_generic::compressMessageSet($this->get()); } - /** * Return result element at specified index (all messages, not roots) @@ -416,17 +392,16 @@ return $data[$index]; } - /** * Returns response parameters e.g. MAILBOX, ORDER * - * @param string $param Parameter name + * @param string $param Parameter name * * @return array|string Response parameters or parameter value */ public function get_parameters($param=null) { - $params = $this->params; + $params = array(); $params['MAILBOX'] = $this->mailbox; $params['ORDER'] = $this->order; @@ -436,7 +411,6 @@ return $params; } - /** * THREAD=REFS sorting implementation (based on provided index) @@ -507,7 +481,6 @@ $this->raw_data = implode(self::SEPARATOR_ELEMENT, $result); } - /** * Returns data as tree * @@ -532,7 +505,6 @@ return $result; } - /** * Returns thread depth and children data * @@ -549,7 +521,6 @@ return array($depth, $children); } - /** * Creates 'depth' and 'children' arrays from stored thread 'tree' data. */ @@ -564,7 +535,6 @@ } } } - /** * Converts part of the raw thread into an array @@ -587,7 +557,6 @@ return $result; } - /** * IMAP THREAD response parser -- Gitblit v1.9.1