Fix Horde_Imap_Client::fetch() with changedsince parameter.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 27 Jan 2010 19:35:11 +0000 (12:35 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 27 Jan 2010 19:35:11 +0000 (12:35 -0700)
For a whole mailbox search with caching, filter out all entries that
have do not fit changedsince criteria. Previously, all non-criteria
matching entities still had an entry in the return array containing the
UID of the message.

framework/Imap_Client/lib/Horde/Imap/Client/Base.php

index 78f67d0..220f3d9 100644 (file)
@@ -2162,7 +2162,16 @@ abstract class Horde_Imap_Client_Base
 
         /* If given sequence numbers, we need to switch to UIDs for caching
          * purposes. Also, we need UID #'s now if searching the entire
-         * mailbox. */
+         * mailbox. However, if we are doing a changedsince since we need to
+         * do that component of the search first to determine exactly what
+         * UIDs we need to fetch. */
+        if (!empty($options['changedsince'])) {
+            if (!($res = $this->_fetch(array(Horde_Imap_Client::FETCH_UID => 1), $options))) {
+                return array();
+            }
+            $options['ids'] = array_keys($res);
+        }
+
         if ($seq || empty($options['ids'])) {
             $res_seq = $this->_getSeqUIDLookup(empty($options['ids']) ? null : $options['ids'], $seq);
             $uids = $res_seq['uids'];