On Fri, Oct 2, 2009 at 12:04 PM, John Campbell <jcampbe...@gmail.com> wrote:
> On Fri, Oct 2, 2009 at 11:21 AM, David Mintz <da...@davidmintz.org> wrote: > > If you were working on a Zend Framework application, and if you were > writing > > a simple script to log into an IMAP email account, fetch messages, > iterate > > through them finding ones matching particular criteria, do something with > > the information in each of those messages, delete the message, and call > it a > > day... And if you found that Zend_Mail_Storage_Imap has a flawed > > implementation of removeMessage(), because it sends an EXPUNGE command on > > every invocation and thereby screws up the class' ArrayAccess > > implementation by disrupting the mapping between message numbers and > > messages... then what would you do? > > So, let me make sure I understand this correctly. Expunge, iirc, > deletes everything marked for deletion, and ZEND calls expunge > immediately after you mark something for deletion, which is not quite > right (but, makes imap behave more like pop). It is unlikely the > class maintainers are going to change that. > > How is the ArrayAccess broken? The key=>message mapping should change > every time you call delete. > I think that's exactly the problem. http://framework.zend.com/issues/browse/ZF-5655 explains it better than I can. And, since my initial post, I went ahead and wrote my own extension stealing all the suggestions provided in the above link. It works. Whoever wrote removeMessage() apparently did have some misgivings about EXPUNGE. Note the TODO comment: public function removeMessage($id) { if (!$this->_protocol->store(array(Zend_Mail_Storage::FLAG_DELETED), $id, null, '+')) { /** * @see Zend_Mail_Storage_Exception */ require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot set deleted flag'); } // TODO: expunge here or at close? we can handle an error here better and are more fail safe if (!$this->_protocol->expunge()) { /** * @see Zend_Mail_Storage_Exception */ require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('message marked as deleted, but could not expunge'); } } I overwrote this method, simply moving the expunge part to __destruct() -- David Mintz http://davidmintz.org/ The subtle source is clear and bright The tributary streams flow through the darkness
_______________________________________________ New York PHP Users Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/Show-Participation