From: Michael M Slusarz Date: Thu, 11 Jun 2009 05:36:23 +0000 (-0600) Subject: Bug #8327: Fix mailbox regeneration on message action X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=381b34d453dd436766d2743dcb5ab583c468aac6;p=horde.git Bug #8327: Fix mailbox regeneration on message action We were regenerating the mailbox immediately after grabbing the cached list, which made the cached list pointless. --- diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 014ad5341..29374dd7c 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -69,18 +69,18 @@ class IMP_Mailbox * It will only create a new instance if no IMP_Mailbox instance with * the same parameters currently exists. * - * @param string $mailbox See IMP_Mailbox constructor. - * @param integer $index See IMP_Mailbox constructor. + * @param string $mailbox See constructor. + * @param integer $uid See constructor. * * @return mixed The created concrete IMP_Mailbox instance, or false * on error. */ - static public function singleton($mailbox, $index = null) + static public function singleton($mailbox, $uid = null) { if (!isset(self::$_instances[$mailbox])) { - self::$_instances[$mailbox] = new IMP_Mailbox($mailbox, $index); - } elseif (!is_null($index)) { - self::$_instances[$mailbox]->setIndex($index); + self::$_instances[$mailbox] = new IMP_Mailbox($mailbox, $uid); + } elseif (!is_null($uid)) { + self::$_instances[$mailbox]->setIndex($uid); } return self::$_instances[$mailbox]; @@ -90,21 +90,21 @@ class IMP_Mailbox * Constructor. * * @param string $mailbox The mailbox to work with. - * @param integer $index The index of the current message. + * @param integer $uid The UID of the current message. */ - protected function __construct($mailbox, $index = null) + protected function __construct($mailbox, $uid = null) { $this->_mailbox = $mailbox; $this->_searchmbox = $GLOBALS['imp_search']->isSearchMbox($mailbox); - if (!is_null($index)) { + if (!is_null($uid)) { /* Try to rebuild sorted information from the session cache. */ if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) { $tmp = unserialize($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]); $this->_sorted = $tmp['s']; $this->_sortedInfo = $tmp['i']; } - $this->setIndex($index); + $this->setIndex($uid); } } @@ -435,12 +435,16 @@ class IMP_Mailbox * Checks to see if the current index is valid. * This function is only useful if an index was passed to the constructor. * + * @param boolean $rebuild Rebuild mailbox list, if needed. + * * @return boolean True if index is valid, false if not. */ - public function isValidIndex() + public function isValidIndex($rebuild = true) { - $this->_rebuild(); - $this->setIndex(0, 'offset'); + if ($rebuild) { + $this->_rebuild(); + $this->setIndex(0, 'offset'); + } return !is_null($this->_arrayIndex); } diff --git a/imp/message.php b/imp/message.php index a96851549..bd39cacd3 100644 --- a/imp/message.php +++ b/imp/message.php @@ -37,7 +37,7 @@ if (!$imp_search->isSearchMbox($imp_mbox['mailbox'])) { /* Make sure we have a valid index. */ $imp_mailbox = &IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['index']); -if (!$imp_mailbox->isValidIndex()) { +if (!$imp_mailbox->isValidIndex(false)) { _returnToMailbox(null, 'message_missing'); require IMP_BASE . '/mailbox.php'; exit;