roundcubemail/program/lib/Roundcube/rcube_imap_cache.php
function get_thread($mailbox)
    {
        if (empty($this->icache[$mailbox])) {
            $this->icache[$mailbox] = array();
        }

        // Seek in internal cache
        if (array_key_exists('thread', $this->icache[$mailbox])) {
            return $this->icache[$mailbox]['thread']['object'];
        }

        // Get thread from DB (if DB wasn't already queried)
        if (empty($this->icache[$mailbox]['thread_queried'])) {
            $index = $this->get_thread_row($mailbox);

            // set the flag that DB was already queried for thread
            // this way we'll be able to skip one SELECT, when
            // get_thread() is called more than once or after clear()
            $this->icache[$mailbox]['thread_queried'] = true;
        }

        // Entry exist, check cache status
        if (!empty($index)) {
            $exists   = true;
            $is_valid = $this->validate($mailbox, $index, $exists);

            if (!$is_valid) {
                $index = null;
            }
        }

        // Index not found or not valid, get index from IMAP server
        if ($index === null) {
            // Get mailbox data (UIDVALIDITY, counters, etc.) for status check
            $mbox_data = $this->imap->folder_data($mailbox);
            // Get THREADS result
            $index['object'] = $this->get_thread_data($mailbox, $mbox_data);

            // insert/update
            $this->add_thread_row($mailbox, $index['object'], $mbox_data, $exists);
        }

        $this->icache[$mailbox]['thread'] = $index;

        return $index['object'];
    }
function get_thread($mailbox)
    {
        if (empty($this->icache[$mailbox])) {
            $this->icache[$mailbox] = array();
        }

        // Seek in internal cache
        if (array_key_exists('thread', $this->icache[$mailbox])) {
            return $this->icache[$mailbox]['thread']['object'];
        }

        // Get thread from DB (if DB wasn't already queried)
        if (empty($this->icache[$mailbox]['thread_queried'])) {
            $index = $this->get_thread_row($mailbox);

            // set the flag that DB was already queried for thread
            // this way we'll be able to skip one SELECT, when
            // get_thread() is called more than once or after clear()
            $this->icache[$mailbox]['thread_queried'] = true;
        }

        // Entry exist, check cache status
        if (!empty($index)) {
            $exists   = true;
            $is_valid = $this->validate($mailbox, $index, $exists);

            if (!$is_valid) {
                $index = null;
            }
        }

        // Index not found or not valid, get index from IMAP server
        if ($index === null) {
            // Get mailbox data (UIDVALIDITY, counters, etc.) for status check
            $mbox_data = $this->imap->folder_data($mailbox);
            // Get THREADS result
            $index['object'] = $this->get_thread_data($mailbox, $mbox_data);

            // insert/update
            $this->add_thread_row($mailbox, $index['object'], $mbox_data, $exists);
        }

        $this->icache[$mailbox]['thread'] = $index;

        return $index['object'];
    }
function get_thread ( $ mailbox ) { if ( empty ( $ this -> icache [ $ mailbox ] ) ) { $ this -> icache [ $ mailbox ] = array ( ) ; } // Seek in internal cache if ( array_key_exists ( 'thread' , $ this -> icache [ $ mailbox ] ) ) { return $ this -> icache [ $ mailbox ] [ 'thread' ] [ 'object' ] ; } // Get thread from DB (if DB wasn't already queried) if ( empty ( $ this -> icache [ $ mailbox ] [ 'thread_queried' ] ) ) { $ index = $ this -> get_thread_row ( $ mailbox ) ; // set the flag that DB was already queried for thread // this way we'll be able to skip one SELECT, when // get_thread() is called more than once or after clear() $ this -> icache [ $ mailbox ] [ 'thread_queried' ] = true ; } // Entry exist, check cache status if ( ! empty ( $ index ) ) { $ exists = true ; $ is_valid = $ this -> validate ( $ mailbox , $ index , $ exists ) ; if ( ! $ is_valid ) { $ index = null ; } } // Index not found or not valid, get index from IMAP server if ( $ index === null ) { // Get mailbox data (UIDVALIDITY, counters, etc.) for status check $ mbox_data = $ this -> imap -> folder_data ( $ mailbox ) ; // Get THREADS result $ index [ 'object' ] = $ this -> get_thread_data ( $ mailbox , $ mbox_data ) ; // insert/update $ this -> add_thread_row ( $ mailbox , $ index [ 'object' ] , $ mbox_data , $ exists ) ; } $ this -> icache [ $ mailbox ] [ 'thread' ] = $ index ; return $ index [ 'object' ] ; }
Return messages thread.
If threaded index doesn't exist or is invalid, will be updated.

@param string $mailbox Folder name

@return array Messages threaded index
Return messages thread . If threaded index doesn t exist or is invalid will be updated .