Skip to content

Commit

Permalink
fallback for incorrectly advertised SORT capability (#51)
Browse files Browse the repository at this point in the history
* Issue 50: fallback for incorrectly advertised SORT capability
* Added @author
fixes #50
  • Loading branch information
mzellho authored and ChristophWurst committed Sep 7, 2016
1 parent 3249331 commit 93eda55
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mailbox.php
Expand Up @@ -11,6 +11,7 @@
* @author Thomas I <thomas@oatr.be>
* @author Thomas Mueller <thomas.mueller@tmit.eu>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Maximilian Zellhofer <max.zellhofer@gmail.com>
*
* Mail
*
Expand Down Expand Up @@ -107,7 +108,16 @@ private function getSearchIds($from, $count, $filter) {
if ($this->getSpecialRole() !== 'trash') {
$query->flag(Horde_Imap_Client::FLAG_DELETED, false);
}
$result = $this->conn->search($this->mailBox, $query, ['sort' => [Horde_Imap_Client::SORT_DATE]]);

try {
$result = $this->conn->search($this->mailBox, $query, ['sort' => [Horde_Imap_Client::SORT_DATE]]);
} catch (Horde_Imap_Client_Exception $e) {
// maybe the server's advertisment of SORT was a fake
// see https://github.com/nextcloud/mail/issues/50
// try again without SORT
return $this->getFetchIds($from, $count);
}

$ids = array_reverse($result['match']->ids);
if ($from >= 0 && $count >= 0) {
$ids = array_slice($ids, $from, $count);
Expand Down

0 comments on commit 93eda55

Please sign in to comment.