From: Michael M Slusarz Date: Wed, 24 Nov 2010 18:50:23 +0000 (-0700) Subject: Fix mailbox list generation in IMP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=809c8971a0bdbb9f7071bcedfcbabbaa9d8017ae;p=horde.git Fix mailbox list generation in IMP In [M]IMP message mode, we want to use a cached version of the mailbox list in order to prevent wild index swings when deleting messages. However, we also need to make sure that we correctly rebuild the mailbox once we return to the mailbox view since things may have changed in the meantime. --- diff --git a/imp/lib/Injector/Factory/MailboxList.php b/imp/lib/Injector/Factory/MailboxList.php index bb1cc337d..406db4666 100644 --- a/imp/lib/Injector/Factory/MailboxList.php +++ b/imp/lib/Injector/Factory/MailboxList.php @@ -88,6 +88,7 @@ class IMP_Injector_Factory_MailboxList case 'imp': case 'mimp': $this->_instances[$mailbox]->setIndex($indices); + $this->_instance[$mailbox]->checkcache = is_null($indices); break; } diff --git a/imp/lib/Mailbox/List/Track.php b/imp/lib/Mailbox/List/Track.php index 5d3561ab1..192323b1f 100644 --- a/imp/lib/Mailbox/List/Track.php +++ b/imp/lib/Mailbox/List/Track.php @@ -17,6 +17,20 @@ class IMP_Mailbox_List_Track extends IMP_Mailbox_List { /** + * Check the IMAP cache ID? + * + * @var boolean + */ + public $checkcache = true; + + /** + * The IMAP cache ID of the mailbox. + * + * @var string + */ + protected $_cacheid = null; + + /** * The location in the sorted array we are at. * * @var integer @@ -28,7 +42,7 @@ class IMP_Mailbox_List_Track extends IMP_Mailbox_List * * @var array */ - protected $_slist = array('_index'); + protected $_slist = array('_cacheid', '_index'); /** * Returns the current message array index. If the array index has @@ -126,6 +140,22 @@ class IMP_Mailbox_List_Track extends IMP_Mailbox_List /** */ + protected function _buildMailbox() + { + $cacheid = $this->getCacheID(); + + /* Check cache ID: will catch changes to the mailbox after coming out + * of message view mode. */ + if (!$this->isBuilt() || + ($this->checkcache && ($this->_cacheid != $cacheid))) { + $this->_sorted = null; + $this->_cacheid = $cacheid; + parent::_buildMailbox(); + } + } + + /** + */ protected function _rebuild($force = false) { if ($force ||