Skip to content

Commit

Permalink
Ensure the IMAP messages exists before fetching the attachment.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed May 28, 2014
1 parent 7f08152 commit 20297eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions framework/ActiveSync/lib/Horde/ActiveSync/Imap/Adapter.php
Expand Up @@ -192,7 +192,7 @@ public function getAttachment($mailbox, $uid, $part)
$imap = $this->_getImapOb();
$mbox = new Horde_Imap_Client_Mailbox($mailbox);
$messages = $this->_getMailMessages($mbox, array($uid));
if (!$messages[$uid]->exists(Horde_Imap_Client::FETCH_STRUCTURE)) {
if (empty($messages[$uid]) || !$messages[$uid]->exists(Horde_Imap_Client::FETCH_STRUCTURE)) {
throw new Horde_ActiveSync_Exception('Message Gone');
}
$msg = new Horde_ActiveSync_Imap_Message($imap, $mbox, $messages[$uid]);
Expand Down Expand Up @@ -1418,7 +1418,7 @@ protected function _getMailMessages(
}
$ids = new Horde_Imap_Client_Ids($uids);
try {
return $imap->fetch($mbox, $query, array('ids' => $ids));
return $imap->fetch($mbox, $query, array('ids' => $ids, 'exists' => true));
} catch (Horde_Imap_Client_Exception $e) {
$this->_logger->err(sprintf(
'[%s] Unable to fetch message: %s',
Expand Down

0 comments on commit 20297eb

Please sign in to comment.