public get ( string $mailbox, array $uids = [], array $fields = [], integer $uidvalid = null ) : array | ||
$mailbox | string | An IMAP mailbox string. |
$uids | array | The list of message UIDs to retrieve information for. If empty, returns the list of cached UIDs. |
$fields | array | An array of fields to retrieve. If empty, returns all cached fields. |
$uidvalid | integer | The IMAP uidvalidity value of the mailbox. |
return | array | An array of arrays with the UID of the message as the key (if found) and the fields as values (will be undefined if not found). If $uids is empty, returns the full (unsorted) list of cached UIDs. |
public function get($mailbox, array $uids = array(), $fields = array(), $uidvalid = null)
{
$mailbox = strval($mailbox);
if (empty($uids)) {
$ret = $this->_backend->getCachedUids($mailbox, $uidvalid);
} else {
$ret = $this->_backend->get($mailbox, $uids, $fields, $uidvalid);
if ($this->_debug && !empty($ret)) {
$this->_debug->info(sprintf('CACHE: Retrieved messages (%s [%s; %s])', empty($fields) ? 'ALL' : implode(',', $fields), $mailbox, $this->_baseob->getIdsOb(array_keys($ret))->tostring_sort));
}
}
return $ret;
}
/** * Synchronizes the current mailbox cache with the server (using CONDSTORE * or QRESYNC). */ protected function _condstoreSync() { $mbox_ob = $this->_mailboxOb(); /* Check that modseqs are available in mailbox. */ if (!($highestmodseq = $mbox_ob->getStatus(Horde_Imap_Client::STATUS_HIGHESTMODSEQ)) || !($modseq = $this->_updateModSeq($highestmodseq))) { $mbox_ob->sync = true; } if ($mbox_ob->sync) { return; } $uids_ob = $this->getIdsOb($this->_cache->get($this->_selected, array(), array(), $mbox_ob->getStatus(Horde_Imap_Client::STATUS_UIDVALIDITY))); if (!count($uids_ob)) { $mbox_ob->sync = true; return; } /* Are we caching flags? */ if (array_key_exists(Horde_Imap_Client::FETCH_FLAGS, $this->_cacheFields())) { $fquery = new Horde_Imap_Client_Fetch_Query(); $fquery->flags(); /* Update flags in cache. Cache will be updated in _fetch(). */ $this->_fetch(new Horde_Imap_Client_Fetch_Results(), array(array('_query' => $fquery, 'changedsince' => $modseq, 'ids' => $uids_ob))); } /* Search for deleted messages, and remove from cache. */ $vanished = $this->vanished($this->_selected, $modseq, array('ids' => $uids_ob)); $disappear = array_diff($uids_ob->ids, $vanished->ids); if (!empty($disappear)) { $this->_deleteMsgs($this->_selected, $this->getIdsOb($disappear)); } $mbox_ob->sync = true; }