From: Michael M Slusarz Date: Wed, 1 Sep 2010 06:21:03 +0000 (-0600) Subject: Fix updating mailbox cache when navigating past end of mailbox on the IMP message... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5c887e326c58c4f1f7462d50f4c9fe533c69a182;p=horde.git Fix updating mailbox cache when navigating past end of mailbox on the IMP message page --- diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 885a20a03..11f1f355e 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -422,16 +422,10 @@ class IMP_Mailbox implements Countable * 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($rebuild = true) { - if ($rebuild) { - $this->_rebuild(); - $this->setIndex(0); - } return !is_null($this->_arrayIndex); } @@ -614,11 +608,15 @@ class IMP_Mailbox implements Countable $this->_arrayIndex = $this->getArrayIndex($uid, $mailbox); } } elseif (!is_null($this->_arrayIndex)) { - $this->_arrayIndex += $data; - if (empty($this->_sorted[$this->_arrayIndex])) { - $this->_arrayIndex = null; + $index = $this->_arrayIndex += $data; + if (isset($this->_sorted[$this->_arrayIndex])) { + $this->_rebuild(); + } else { + $this->_rebuild(true); + $this->_arrayIndex = isset($this->_sorted[$index]) + ? $index + : null; } - $this->_rebuild(); } } @@ -734,9 +732,6 @@ class IMP_Mailbox implements Countable return; } - $msgcount = 0; - $sortcount = count($this->_sorted); - /* Remove the current entry and recalculate the range. */ foreach ($indices as $mbox => $uid) { $val = $this->getArrayIndex($uid, $mbox); @@ -744,7 +739,6 @@ class IMP_Mailbox implements Countable if ($this->_searchmbox) { unset($this->_sortedMbox[$val]); } - ++$msgcount; } $this->_sorted = array_values($this->_sorted); diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 8f9e8b6f1..eb833825d 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -30,7 +30,7 @@ $vars = Horde_Variables::getDefaultVariables(); /* Make sure we have a valid index. */ $imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid)); -if (!$imp_mailbox->isValidIndex(false)) { +if (!$imp_mailbox->isValidIndex()) { IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect(); } diff --git a/imp/message.php b/imp/message.php index 464d9b3ba..9f2cfa321 100644 --- a/imp/message.php +++ b/imp/message.php @@ -35,7 +35,7 @@ if (!($search_mbox = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$ma /* Make sure we have a valid index. */ $imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid)); -if (!$imp_mailbox->isValidIndex(false)) { +if (!$imp_mailbox->isValidIndex()) { _returnToMailbox(null, 'message_missing'); require IMP_BASE . '/mailbox.php'; exit;