Aleksander Machniak
2015-11-05 e7d1a80a800f6f08c0a683d2be04b0db2a1f6523
program/lib/Roundcube/rcube_imap_cache.php
@@ -171,7 +171,7 @@
        // Seek in internal cache
        if (array_key_exists('index', $this->icache[$mailbox])) {
            // The index was fetched from database already, but not validated yet
            if (!array_key_exists('object', $this->icache[$mailbox]['index'])) {
            if (empty($this->icache[$mailbox]['index']['validated'])) {
                $index = $this->icache[$mailbox]['index'];
            }
            // We've got a valid index
@@ -248,6 +248,7 @@
        }
        $this->icache[$mailbox]['index'] = array(
            'validated'  => true,
            'object'     => $data,
            'sort_field' => $sort_field,
            'modseq'     => !empty($index['modseq']) ? $index['modseq'] : $mbox_data['HIGHESTMODSEQ']
@@ -890,6 +891,8 @@
            return false;
        }
        $index['validated'] = true;
        // Get mailbox data (UIDVALIDITY, counters, etc.) for status check
        $mbox_data = $this->imap->folder_data($mailbox);
@@ -1232,12 +1235,14 @@
    private function message_object_prepare(&$msg, &$size = 0)
    {
        // Remove body too big
        if ($msg->body && ($length = strlen($msg->body))) {
            $size += $length;
        if (isset($msg->body)) {
            $length = strlen($msg->body);
            if ($size > $this->threshold * 1024) {
                $size -= $length;
            if ($msg->body_modified || $size + $length > $this->threshold * 1024) {
                unset($msg->body);
            }
            else {
                $size += $length;
            }
        }
@@ -1250,10 +1255,8 @@
        unset($msg->replaces);
        if (is_array($msg->structure->parts)) {
            foreach ($msg->structure->parts as $part) {
                $this->message_object_prepare($part, $size);
            }
        if (is_object($msg->structure)) {
            $this->message_object_prepare($msg->structure, $size);
        }
        if (is_array($msg->parts)) {