$status = $this->status($mailbox, $query);
- $data = $condstore
- ? array($status['highestmodseq'], $status['uidvalidity'])
- : array($status['uidvalidity'], $status['uidnext'], $status['messages']);
+ if ($condstore) {
+ return implode('|', array($status['highestmodseq'], $status['uidvalidity']));
+ }
+
+ if (empty($status['uidnext'])) {
+ /* UIDNEXT is not strictly required on mailbox open. If it is
+ * not available, use the last UID in the mailbox instead. */
+ $search_res = $this->fetch($this->_selected, array(Horde_Imap_Client::FETCH_UID => true), array('ids' => array('*'), 'sequence' => true));
+ $result = reset($search_res);
+ $status['uidnext'] = $result['uid'];
+ }
- return implode('|', $data);
+ return implode('|', array($status['uidvalidity'], $status['uidnext'], $status['messages']));
}
/**
if ($mailbox == $this->_selected) {
if (isset($this->_temp['mailbox'][$val])) {
$data[$val] = $this->_temp['mailbox'][$val];
+ } elseif ($key == Horde_Imap_Client::STATUS_UIDNEXT) {
+ /* UIDNEXT is not strictly required on mailbox open.
+ * See RFC 3501 [6.3.1]. */
+ $data[$val] = 0;
} else {
if ($key == Horde_Imap_Client::STATUS_UIDNOTSTICKY) {
/* In the absence of uidnotsticky information, or