[dev] [Corrected] Horde_Imap_Client and fetching vanished messages.

Michael J Rubinsky mrubinsk at horde.org
Tue Jan 10 18:42:17 UTC 2012


Quoting Michael M Slusarz <slusarz at horde.org>:

> Quoting Michael J Rubinsky <mrubinsk at horde.org>:
>
>> I'm trying to get a set of uids that have been expunged since a  
>> specific modseq value.
>
> [snip]
>
>> Then, I "read" a single email in my INBOX do NOT change anything else:
>>
>> <code>
>> $results = $imap->fetch(
>>    $mbox,
>>    $q,
>>    array('changedsince' => 379323,
>>          'vanished' => true)
>> );
>>
>> var_dump($results);
>> </code>
>>
>> <output>
>> array(1) {
>> [91203]=>
>>  object(Horde_Imap_Client_Data_Fetch)#510 (1) {
>>    ["_data":protected]=>
>>    array(3) {
>>      [14]=>
>>      int(34)
>>      [13]=>
>>      int(91203)
>>      [15]=>
>>      int(379363)
>>    }
>>  }
>> </output>
>>
>> Am I doing something wrong?
>
> Looks like there is some errors in the Horde_Imap_Client code  
> dealing with the 'vanished' parameter (namely, the fact that it is  
> never used in Socket.php).  So that will need to be fixed.
>
> That being said, the question becomes: why are you using  
> changedsince/vanished at all?  Generally, you shouldn't need to use  
> these parameters at all; they are used internally for caching  
> purposes instead, the reason being that QRESYNC will not be  
> available on many IMAP servers, so this code won't work at all  
> unless you are doing some kind of branching operation.  This kind of  
> abstraction should/is done in the Horde_Imap_Client code, not  
> application code.

Some background: This code is all for the purpose of syncing email  
over ActiveSync. I'm using modseq and changedsince to retrieve the  
uids of any recently changed email. In this context, 'changed' would  
mean a new, never before seen email, or an email that has had the seen  
flag added or removed. I'm initially fetching the complete list of  
uids from the server and storing the uids, the seen status and the  
highest modseq value. When the device sends a PING request, the server  
esentially performs a loop like the following psuedocode:

do while (!heartbeat_timeout()) {
  foreach (collection) {
   check_for_backend_changes()
   if (have_changes) {
      notifiy_client_of_changes()
      terminate_ping()
   } else {
      wait_for_a_configured_time()
   }
  }
}

If I don't use 'changedsince', I would have to retrieve the complete  
set of UIDs again, along with flags and compare each message with my  
stored device state. I also have to compare the list of UIDs on the  
server with the UIDs known to be on the client to determine which  
messages have been expunged/deleted as well - which is what I was  
hoping 'vansihed' would have helped with (I'm currently just  
array_diff()ing the server uid list with the devices uid list to  
determine this). Caching in the imap client would obviously help with  
imap server load, but given how frequently this must occur, I'd like  
to avoid having to iterate over each message to check the status of  
the flags to determine what has changed. Using changedsince gets me  
only the messages that have changed, greatly reducing the number of  
messages I'd have to iterate. We discussed briefly in IRC the  
possibility of just requiring a IMAP server that supports the needed  
extensions for this to work. Even if we decide to not require this in  
the future, it would still be nice to provide the enhanced performance  
for those servers that *do* support it.

..or am I missing/misunderstanding something?

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org




More information about the dev mailing list