Aleksander Machniak
2013-10-17 037af6890fe6fdb84a08d3c86083e847c90ec0ad
program/lib/Roundcube/rcube_imap_cache.php
@@ -2,8 +2,6 @@
/*
 +-----------------------------------------------------------------------+
 | program/include/rcube_imap_cache.php                                  |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
 |                                                                       |
@@ -13,13 +11,11 @@
 |                                                                       |
 | PURPOSE:                                                              |
 |   Caching of IMAP folder contents (messages and index)                |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 | Author: Aleksander Machniak <alec@alec.pl>                            |
 +-----------------------------------------------------------------------+
*/
/**
 * Interface class for accessing Roundcube messages cache
@@ -411,8 +407,8 @@
            return;
        }
        $msg   = serialize($this->db->encode(clone $message));
        $flags = 0;
        $msg   = clone $message;
        if (!empty($message->flags)) {
            foreach ($this->flags as $idx => $flag) {
@@ -421,7 +417,9 @@
                }
            }
        }
        unset($msg->flags);
        $msg = $this->db->encode($msg, true);
        // update cache record (even if it exists, the update
        // here will work as select, assume row exist if affected_rows=0)
@@ -489,7 +487,7 @@
            .", flags = flags ".($enabled ? "+ $idx" : "- $idx")
            ." WHERE user_id = ?"
                ." AND mailbox = ?"
                .($uids !== null ? " AND uid IN (".$this->db->array2list($uids, 'integer').")" : "")
                .(!empty($uids) ? " AND uid IN (".$this->db->array2list($uids, 'integer').")" : "")
                ." AND (flags & $idx) ".($enabled ? "= 0" : "= $idx"),
            $this->userid, $mailbox);
    }
@@ -643,7 +641,7 @@
        if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
            $data  = explode('@', $sql_arr['data']);
            $index = @unserialize($data[0]);
            $index = $this->db->decode($data[0], true);
            unset($data[0]);
            if (empty($index)) {
@@ -680,7 +678,7 @@
        if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
            $data   = explode('@', $sql_arr['data']);
            $thread = @unserialize($data[0]);
            $thread = $this->db->decode($data[0], true);
            unset($data[0]);
            if (empty($thread)) {
@@ -706,7 +704,7 @@
        $data, $mbox_data = array(), $exists = false, $modseq = null)
    {
        $data = array(
            serialize($data),
            $this->db->encode($data, true),
            $sort_field,
            (int) $this->skip_deleted,
            (int) $mbox_data['UIDVALIDITY'],
@@ -739,7 +737,7 @@
    private function add_thread_row($mailbox, $data, $mbox_data = array(), $exists = false)
    {
        $data = array(
            serialize($data),
            $this->db->encode($data, true),
            (int) $this->skip_deleted,
            (int) $mbox_data['UIDVALIDITY'],
            (int) $mbox_data['UIDNEXT'],
@@ -1071,7 +1069,7 @@
     */
    private function build_message($sql_arr)
    {
        $message = $this->db->decode(unserialize($sql_arr['data']));
        $message = $this->db->decode($sql_arr['data'], true);
        if ($message) {
            $message->flags = array();