Fix infinite loop if using cache and server does not support UIDNEXT
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 15 Dec 2009 09:26:07 +0000 (02:26 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 15 Dec 2009 09:26:07 +0000 (02:26 -0700)
framework/Imap_Client/lib/Horde/Imap/Client/Base.php
framework/Imap_Client/lib/Horde/Imap/Client/Socket.php

index ff9d41a..4628b98 100644 (file)
@@ -207,7 +207,8 @@ abstract class Horde_Imap_Client_Base
      */
     protected function _initCache($current = false)
     {
-        if (empty($this->_params['cache']['fields'])) {
+        if (empty($this->_params['cache']['fields']) ||
+            !empty($this->_temp['nocache'])) {
             return false;
         }
 
@@ -2629,9 +2630,10 @@ abstract class Horde_Imap_Client_Base
         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'];
+            $this->_temp['nocache'] = true;
+            $search_res = $this->_getSeqUIDLookup(array($status['messages']), true);
+            unset($this->_temp['nocache']);
+            $status['uidnext'] = reset($search_res['uids']);
         }
 
         return implode('|', array($status['uidvalidity'], $status['uidnext'], $status['messages']));
index 87c1d4b..06042d3 100644 (file)
@@ -4080,4 +4080,5 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
             break;
         }
     }
+
 }