Fix list when dealing with empty mailboxes
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Mar 2009 19:04:26 +0000 (13:04 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Mar 2009 19:04:26 +0000 (13:04 -0600)
framework/Imap_Client/lib/Horde/Imap/Client/Base.php

index ba111a1..1d1ef95 100644 (file)
@@ -2330,12 +2330,16 @@ abstract class Horde_Imap_Client_Base
         $res = $this->search($this->_selected, $search, array('sort' => array(Horde_Imap_Client::SORT_ARRIVAL)));
         $ret = array('uids' => $res['sort']);
         if ($seq) {
-            if (empty($ids)) {
-                $ids = range(1, count($ret['uids']));
+            if (!$res['count']) {
+                $ret['lookup'] = array();
             } else {
-                sort($ids, SORT_NUMERIC);
+                if (empty($ids)) {
+                    $ids = range(1, $res['count']);
+                } else {
+                    sort($ids, SORT_NUMERIC);
+                }
+                $ret['lookup'] = array_combine($ret['uids'], $ids);
             }
-            $ret['lookup'] = array_combine($ret['uids'], $ids);
         }
 
         return $ret;