From 92dd1eb28d591865518ac5e9a8016029f1487d94 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 27 Sep 2010 15:31:22 -0600 Subject: [PATCH] Split IMP_Mailbox into two separate classes. One holds the sorted list information, one extends to include array index tracking (since this part of the class is only used in the message views of IMP/MIMP). Improve serialization of this data. --- imp/config/hooks.php.dist | 6 +- imp/lib/Ajax/Application.php | 8 +- imp/lib/Application.php | 2 +- imp/lib/Indices.php | 4 +- .../Binder/{Mailbox.php => MailboxList.php} | 6 +- imp/lib/Injector/Factory/Mailbox.php | 74 ------- imp/lib/Injector/Factory/MailboxList.php | 126 +++++++++++ imp/lib/{Mailbox.php => Mailbox/List.php} | 237 ++++++++------------- imp/lib/Mailbox/List/Track.php | 155 ++++++++++++++ imp/lib/Message.php | 8 +- imp/lib/Spam.php | 2 +- imp/lib/Views/ListMessages.php | 12 +- imp/mailbox-mimp.php | 2 +- imp/mailbox.php | 2 +- imp/message-mimp.php | 2 +- imp/message.php | 2 +- imp/rss.php | 2 +- imp/thread.php | 2 +- 18 files changed, 404 insertions(+), 248 deletions(-) rename imp/lib/Injector/Binder/{Mailbox.php => MailboxList.php} (76%) delete mode 100644 imp/lib/Injector/Factory/Mailbox.php create mode 100644 imp/lib/Injector/Factory/MailboxList.php rename imp/lib/{Mailbox.php => Mailbox/List.php} (83%) create mode 100644 imp/lib/Mailbox/List/Track.php diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 7728c4795..3c46f3159 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -272,9 +272,9 @@ class IMP_Hooks * mailbox. * * @param array $data The overview information for a message as returned - * from the IMP_Mailbox::getMailboxArray() call (see - * lib/Mailbox.php for documentation on the structure - * of the array). + * from the IMP_Mailbox_List::getMailboxArray() call + * (see lib/Mailbox/List.php for documentation on the + * structure of the array). * @param string $mode Either 'imp' or 'dimp'. * * @return array An array of additional flags to add. These flags must be diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index bb6c81083..b3f005a32 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -731,7 +731,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $result->ViewPort = $this->_viewPortData(true); } else { $result->ViewPort = new stdClass; - $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($this->_vars->view)->getCacheID($this->_vars->view); + $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view); $result->ViewPort->view = $this->_vars->view; } return $result; @@ -925,7 +925,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $result = $this->_checkUidvalidity($result); } elseif (!$change) { /* Only update cacheid info if it changed. */ - $cacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($this->_vars->view)->getCacheID($this->_vars->view); + $cacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view); if ($cacheid != $this->_vars->cacheid) { $result->ViewPort = new stdClass; $result->ViewPort->updatecacheid = $cacheid; @@ -1874,7 +1874,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $result->ViewPort = $this->_viewPortData(true); } else { $result->ViewPort = new stdClass; - $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($this->_vars->view)->getCacheID($this->_vars->view); + $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view); $result->ViewPort->view = $this->_vars->view; } @@ -1923,7 +1923,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application } } - return ($GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid); + return ($GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid); } /** diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 270888875..c5a013a4c 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -99,7 +99,7 @@ class IMP_Application extends Horde_Registry_Application 'IMP_Imap' => 'IMP_Injector_Binder_Imap', 'IMP_Imap_Tree' => 'IMP_Injector_Binder_Imaptree', 'IMP_Mail' => 'IMP_Injector_Binder_Mail', - 'IMP_Mailbox' => 'IMP_Injector_Binder_Mailbox', + 'IMP_Mailbox_List' => 'IMP_Injector_Binder_MailboxList', 'IMP_Mime_Viewer' => 'IMP_Injector_Binder_MimeViewer', 'IMP_Quota' => 'IMP_Injector_Binder_Quota', 'IMP_Search' => 'IMP_Injector_Binder_Search', diff --git a/imp/lib/Indices.php b/imp/lib/Indices.php index b70edafb2..b588a97ba 100644 --- a/imp/lib/Indices.php +++ b/imp/lib/Indices.php @@ -53,7 +53,7 @@ class IMP_Indices implements Countable, Iterator * + IMP_Compose object * + IMP_Contents object * + IMP_Indices object - * + IMP_Mailbox object + * + IMP_Mailbox_List_Track object * + String * Format: IMAP sequence string * @@ -92,7 +92,7 @@ class IMP_Indices implements Countable, Iterator ); } elseif ($data instanceof IMP_Indices) { $indices = $data->indices(); - } elseif ($data instanceof IMP_Mailbox) { + } elseif ($data instanceof IMP_Mailbox_List_Track) { $idx = $data->getIMAPIndex(); $indices = array( $idx['mailbox'] => array($idx['uid']) diff --git a/imp/lib/Injector/Binder/Mailbox.php b/imp/lib/Injector/Binder/MailboxList.php similarity index 76% rename from imp/lib/Injector/Binder/Mailbox.php rename to imp/lib/Injector/Binder/MailboxList.php index 07bae9a55..b8b329ca2 100644 --- a/imp/lib/Injector/Binder/Mailbox.php +++ b/imp/lib/Injector/Binder/MailboxList.php @@ -1,6 +1,6 @@ - * @category Horde - * @license http://www.fsf.org/copyleft/gpl.html GPL - * @link http://pear.horde.org/index.php?package=IMP - * @package IMP - */ - -/** - * A Horde_Injector:: based IMP_Mailbox:: factory. - * - * Copyright 2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - * - * @author Michael Slusarz - * @category Horde - * @license http://www.fsf.org/copyleft/gpl.html GPL - * @link http://pear.horde.org/index.php?package=IMP - * @package IMP - */ -class IMP_Injector_Factory_Mailbox -{ - /** - * Instances. - * - * @var array - */ - private $_instances = array(); - - /** - * The injector. - * - * @var Horde_Injector - */ - private $_injector; - - /** - * Constructor. - * - * @param Horde_Injector $injector The injector to use. - */ - public function __construct(Horde_Injector $injector) - { - $this->_injector = $injector; - } - - /** - * Return the IMP_Mailbox:: instance. - * - * @param string $mailbox The mailbox name. - * @param IMP_Indices $indices An indices object. - * - * @return IMP_Mailbox The singleton mailbox instance. - * @throws IMP_Exception - */ - public function getOb($mailbox, $indices = null) - { - if (!isset($this->_instances[$mailbox])) { - $this->_instances[$mailbox] = new IMP_Mailbox($mailbox, $indices); - } elseif (!is_null($indices)) { - $this->_instances[$mailbox]->setIndex($indices); - } - - return $this->_instances[$mailbox]; - } - -} diff --git a/imp/lib/Injector/Factory/MailboxList.php b/imp/lib/Injector/Factory/MailboxList.php new file mode 100644 index 000000000..ff4d71d52 --- /dev/null +++ b/imp/lib/Injector/Factory/MailboxList.php @@ -0,0 +1,126 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @link http://pear.horde.org/index.php?package=IMP + * @package IMP + */ + +/** + * A Horde_Injector:: based IMP_Mailbox_List:: factory. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @author Michael Slusarz + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @link http://pear.horde.org/index.php?package=IMP + * @package IMP + */ +class IMP_Injector_Factory_MailboxList +{ + /** + * Instances. + * + * @var array + */ + private $_instances = array( + 'list' => array(), + 'track' => array() + ); + + /** + * The injector. + * + * @var Horde_Injector + */ + private $_injector; + + /** + * Constructor. + * + * @param Horde_Injector $injector The injector to use. + */ + public function __construct(Horde_Injector $injector) + { + $this->_injector = $injector; + + register_shutdown_function(array($this, 'shutdown')); + } + + /** + * Return the IMP_Mailbox_List:: instance. + * + * @param string $mailbox The mailbox name. + * + * @return IMP_Mailbox_List The singleton mailbox instance. + * @throws IMP_Exception + */ + public function getList($mailbox) + { + if (!isset($this->_instances['list'][$mailbox])) { + $this->_instances['list'][$mailbox] = new IMP_Mailbox_List($mailbox); + } + + return $this->_instances['list'][$mailbox]; + } + + /** + * Return the IMP_Mailbox_List_Track:: instance. + * + * @param string $mailbox The mailbox name. + * @param IMP_Indices $indices An indices object. + * + * + * @return IMP_Mailbox_List_Track The singleton mailbox instance. + * @throws IMP_Exception + */ + public function getListTrack($mailbox, $indices = null) + { + if (!isset($this->_instances['track'][$mailbox])) { + $ob = null; + if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) { + try { + $ob = @unserialize($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]); + } catch (Exception $e) {} + } + + if (!$ob) { + $ob = new IMP_Mailbox_List_Track($mailbox); + } + + $this->_instances['track'][$mailbox] = $ob; + } + + if (!is_null($indices)) { + $this->_instances['track'][$mailbox]->setIndex($indices); + } + + return $this->_instances['track'][$mailbox]; + } + + /** + * Tasks to perform on shutdown. + */ + public function shutdown() + { + /* Cache mailbox information if viewing in standard (IMP) message + * mode. Needed to keep navigation consistent when moving through the + * message list, and to ensure messages aren't marked as missing in + * search mailboxes (e.g. if search is dependent on unseen flag). */ + foreach ($this->_instances['track'] as $key => $val) { + if ($val->changed) { + $_SESSION['imp']['cache']['imp_mailbox'][$key] = serialize($val); + } + } + } + +} diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox/List.php similarity index 83% rename from imp/lib/Mailbox.php rename to imp/lib/Mailbox/List.php index 7fd96ec27..13b8a9db6 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox/List.php @@ -1,6 +1,6 @@ _mailbox = $mailbox; $this->_searchmbox = $GLOBALS['injector']->getInstance('IMP_Search')->isSearchMbox($mailbox); - - if (is_null($indices)) { - unset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]); - } else { - /* Try to rebuild sorted information from the session cache. */ - if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) { - $tmp = json_decode($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]); - $this->_sorted = $this->_searchmbox ? $tmp->s : $tmp; - $this->_sortedMbox = $this->_searchmbox ? $tmp->m : array(); - } - $this->setIndex($indices); - } - - register_shutdown_function(array($this, 'shutdown')); - } - - /** - * Cache mailbox information if viewing in standard (IMP) message mode. - * Needed to keep navigation consistent when moving through the message - * list, and to ensure messages aren't marked as missing in search - * mailboxes (e.g. if search is dependent on unseen flag). - */ - public function shutdown() - { - if ($this->_changed && - ($_SESSION['imp']['view'] == 'imp')) { - /* Casting $_sorted to integers saves a significant amount of - * space when json_encoding (no need to quote every value). Only - * can do for IMAP though (since POP3 UIDs are not limited to - * integers). */ - $sorted = ($_SESSION['imp']['protocol'] == 'pop') - ? $this->_sorted - : array_map('intval', $this->_sorted); - $_SESSION['imp']['cache']['imp_mailbox'][$this->_mailbox] = $this->_searchmbox - ? json_encode(array('m' => $this->_sortedMbox, 's' => $sorted)) - : json_encode($sorted); - } } /** @@ -281,7 +246,7 @@ class IMP_Mailbox implements Countable return; } - $this->_changed = true; + $this->changed = true; $this->_sorted = $this->_sortedMbox = array(); $query = null; @@ -408,51 +373,6 @@ class IMP_Mailbox implements Countable } /** - * Returns the current message array index. If the array index has - * run off the end of the message array, will return the last index. - * - * @return integer The message array index. - */ - public function getMessageIndex() - { - return is_null($this->_arrayIndex) ? 1 : $this->_arrayIndex + 1; - } - - /** - * Checks to see if the current index is valid. - * This function is only useful if an index was passed to the constructor. - * - * @return boolean True if index is valid, false if not. - */ - public function isValidIndex($rebuild = true) - { - return !is_null($this->_arrayIndex); - } - - /** - * Returns IMAP mbox/UID information on a message. - * - * @param integer $offset The offset from the current message. - * - * @return array Array with the following entries: - *
-     * 'mailbox' - (string) The mailbox.
-     * 'uid' - (integer) The message UID.
-     * 
- */ - public function getIMAPIndex($offset = 0) - { - $index = $this->_arrayIndex + $offset; - - return isset($this->_sorted[$index]) - ? array( - 'mailbox' => ($this->_searchmbox ? $this->_sortedMbox[$index] : $this->_mailbox), - 'uid' => $this->_sorted[$index] - ) - : array(); - } - - /** * Using the preferences and the current mailbox, determines the messages * to view on the current page. * @@ -521,7 +441,7 @@ class IMP_Mailbox implements Countable $ret['pagecount'] = 1; } - $ret['index'] = ($this->_searchmbox) ? ($ret['begin'] - 1) : $this->_arrayIndex; + $ret['index'] = $ret['begin'] - 1; /* If there are no viewable messages, check for deleted messages in the mailbox. */ @@ -592,35 +512,6 @@ class IMP_Mailbox implements Countable } /** - * Updates the message array index. - * - * @param mixed $data If an integer, the number of messages to increase - * array index by. If an indices object, sets array - * index to the index value. - */ - public function setIndex($data) - { - if ($data instanceof IMP_Indices) { - list($mailbox, $uid) = $data->getSingle(); - $this->_arrayIndex = $this->getArrayIndex($uid, $mailbox); - if (empty($this->_arrayIndex)) { - $this->_rebuild(true); - $this->_arrayIndex = $this->getArrayIndex($uid, $mailbox); - } - } elseif (!is_null($this->_arrayIndex)) { - $index = $this->_arrayIndex += $data; - if (isset($this->_sorted[$this->_arrayIndex])) { - $this->_rebuild(); - } else { - $this->_rebuild(true); - $this->_arrayIndex = isset($this->_sorted[$index]) - ? $index - : null; - } - } - } - - /** * Get the Horde_Imap_Client_Thread object for the current mailbox. * * @return Horde_Imap_Client_Thread The thread object for the current @@ -648,8 +539,7 @@ class IMP_Mailbox implements Countable */ protected function _rebuild($force = false) { - if ($force || - (!is_null($this->_arrayIndex) && !$this->getIMAPIndex(1))) { + if ($force) { $this->_sorted = null; $this->_buildMailbox(); } @@ -720,16 +610,18 @@ class IMP_Mailbox implements Countable * * @param mixed $indices An IMP_Indices object or true to remove all * messages in the mailbox. + * + * @return boolean True if the message was removed from the mailbox. */ public function removeMsgs($indices) { if ($indices === true) { $this->_rebuild(true); - return; + return false; } if (!count($indices)) { - return; + return false; } /* Remove the current entry and recalculate the range. */ @@ -741,17 +633,14 @@ class IMP_Mailbox implements Countable } } + $this->changed = true; $this->_sorted = array_values($this->_sorted); - $this->_changed = true; if ($this->_searchmbox) { $this->_sortedMbox = array_values($this->_sortedMbox); } - $this->_threadob = null; - /* Update the current array index to its new position in the message - * array. */ - $this->setIndex(0); + return true; } /** @@ -789,4 +678,64 @@ class IMP_Mailbox implements Countable return count($this->_sorted); } + /* Serializable methods. */ + + /** + * Serialization. + * + * @return string Serialized data. + */ + public function serialize() + { + $data = array( + 'm' => $this->_mailbox, + 's' => $this->_searchmbox, + 'v' => self::VERSION + ); + + if (!is_null($this->_sorted)) { + $data['so'] = $this->_sorted; + if (!empty($this->_sortedmbox)) { + $data['som'] = $this->_sortedmbox; + } + } + + foreach ($this->_slist as $val) { + $data[$val] = $this->$val; + } + + return json_encode($data); + } + + /** + * Unserialization. + * + * @param string $data Serialized data. + * + * @throws Exception + */ + public function unserialize($data) + { + $data = json_decode($data, true); + if (!is_array($data) || + !isset($data['v']) || + ($data['v'] != self::VERSION)) { + throw new Exception('Cache version change'); + } + + $this->_mailbox = $data['m']; + $this->_searchmbox = $data['s']; + + if (isset($data['so'])) { + $this->_sorted = $data['so']; + if (isset($data['som'])) { + $this->_sortedmbox = $data['som']; + } + } + + foreach ($this->_slist as $val) { + $this->$val = $data[$val]; + } + } + } diff --git a/imp/lib/Mailbox/List/Track.php b/imp/lib/Mailbox/List/Track.php new file mode 100644 index 000000000..761c836a8 --- /dev/null +++ b/imp/lib/Mailbox/List/Track.php @@ -0,0 +1,155 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +class IMP_Mailbox_List_Track extends IMP_Mailbox_List +{ + /** + * The location in the sorted array we are at. + * + * @var integer + */ + protected $_index = null; + + /** + * The list of additional variables to serialize. + * + * @var array + */ + protected $_slist = array('_index'); + + /** + * Returns the current message array index. If the array index has + * run off the end of the message array, will return the last index. + * + * @return integer The message array index. + */ + public function getMessageIndex() + { + return $this->isValidIndex() + ? ($this->_index + 1) + : 1; + } + + /** + * Checks to see if the current index is valid. + * + * @return boolean True if index is valid, false if not. + */ + public function isValidIndex() + { + return !is_null($this->_index); + } + + /** + * Returns IMAP mbox/UID information on a message. + * + * @param integer $offset The offset from the current message. + * + * @return array Array with the following entries: + *
+     * 'mailbox' - (string) The mailbox.
+     * 'uid' - (integer) The message UID.
+     * 
+ */ + public function getIMAPIndex($offset = 0) + { + $index = $this->_index + $offset; + + return isset($this->_sorted[$index]) + ? array( + 'mailbox' => ($this->_searchmbox ? $this->_sortedMbox[$index] : $this->_mailbox), + 'uid' => $this->_sorted[$index] + ) + : array(); + } + + /** + * Using the preferences and the current mailbox, determines the messages + * to view on the current page. + * + * @see parent::buildMailboxPage() + */ + public function buildMailboxPage($page = 0, $start = 0, $opts = array()) + { + $ret = parent::buildMailboxPage($page, $start, $opts); + + if (!$this->_searchmbox) { + $ret['index'] = $this->_index; + } + + return $ret; + } + + /** + * Updates the message array index. + * + * @param mixed $data If an integer, the number of messages to increase + * array index by. If an indices object, sets array + * index to the index value. + */ + public function setIndex($data) + { + if ($data instanceof IMP_Indices) { + list($mailbox, $uid) = $data->getSingle(); + $this->_index = $this->getArrayIndex($uid, $mailbox); + if (empty($this->_index)) { + $this->_rebuild(true); + $this->_index = $this->getArrayIndex($uid, $mailbox); + } + } elseif (!is_null($this->_index)) { + $index = $this->_index += $data; + if (isset($this->_sorted[$this->_index])) { + $this->_rebuild(); + } else { + $this->_rebuild(true); + $this->_index = isset($this->_sorted[$index]) + ? $index + : null; + } + } + } + + /** + * Determines if a rebuild is needed, and, if necessary, performs + * the rebuild. + * + * @param boolean $force Force a rebuild? + */ + protected function _rebuild($force = false) + { + if ($force || + (!is_null($this->_index) && !$this->getIMAPIndex(1))) { + $this->_sorted = null; + $this->_buildMailbox(); + } + } + + /** + * Returns the current sorted array without the given messages. + * + * @param mixed $indices An IMP_Indices object or true to remove all + * messages in the mailbox. + */ + public function removeMsgs($indices) + { + if (parent::removeMsgs($indices)) { + /* Update the current array index to its new position in the + * message array. */ + $this->setIndex(0); + } + } + +} diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 7b4321e31..4093d78c1 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -50,7 +50,7 @@ class IMP_Message *
      * 'create' - (boolean) Should the target mailbox be created?
      *            DEFAULT: false
-     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     * 'mailboxob' - (IMP_Mailbox_List) Update this mailbox object.
      *               DEFAULT: No update.
      * 
* @@ -167,7 +167,7 @@ class IMP_Message *
      * 'keeplog' - (boolean) Should any history information of the message be
      *             kept?
-     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     * 'mailboxob' - (IMP_Mailbox_List) Update this mailbox object.
      *               DEFAULT: No update.
      * 'nuke' - (boolean) Override user preferences and nuke (i.e. permanently
      *          delete) the messages instead?
@@ -472,7 +472,7 @@ class IMP_Message
      *                              parts are stripped if null.
      * @param array $opts           Additional options:
      * 
-     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     * 'mailboxob' - (IMP_Mailbox_List) Update this mailbox object.
      *               DEFAULT: No update.
      * 
* @@ -704,7 +704,7 @@ class IMP_Message *
      * 'list' - (boolean) Return a list of messages expunged.
      *          DEFAULT: false
-     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     * 'mailboxob' - (IMP_Mailbox_List) Update this mailbox object.
      *               DEFAULT: No update.
      * 
* diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 545ec1fd9..c9e3cb23b 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -23,7 +23,7 @@ class IMP_Spam * @param string $action Either 'spam' or 'notspam'. * @param array $opts Additional options: *
-     * 'mailboxob' - (IMP_Mailbox) Update this mailbox object.
+     * 'mailboxob' - (IMP_Mailbox_List) Update this mailbox list object.
      *               DEFAULT: No update.
      * 'noaction' - (boolean) Don't perform any action after reporting?
      *              DEFAULT: false
diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php
index 6ca9f8eed..648b890e5 100644
--- a/imp/lib/Views/ListMessages.php
+++ b/imp/lib/Views/ListMessages.php
@@ -108,7 +108,7 @@ class IMP_Views_ListMessages
         }
 
         /* Generate the sorted mailbox list now. */
-        $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox')->getOb($mbox);
+        $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($mbox);
         $sorted_list = $imp_mailbox->getSortedList();
         $msgcount = count($sorted_list['s']);
 
@@ -379,11 +379,11 @@ class IMP_Views_ListMessages
     /**
      * Obtains IMAP overview data for a given set of message UIDs.
      *
-     * @param IMP_Mailbox $imp_mailbox  An IMP_Mailbox:: object.
-     * @param string $folder            The current folder.
-     * @param array $msglist            The list of message sequence numbers
-     *                                  to process.
-     * @param boolean $search           Is this a search mbox?
+     * @param IMP_Mailbox_List $imp_mailbox  The mailbox list  object.
+     * @param string $folder                 The current folder.
+     * @param array $msglist                 The list of message sequence
+     *                                       numbers to process.
+     * @param boolean $search                Is this a search mbox?
      *
      * @return array  TODO
      * @throws Horde_Exception
diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php
index 0a982d1fd..0163b5e93 100644
--- a/imp/mailbox-mimp.php
+++ b/imp/mailbox-mimp.php
@@ -127,7 +127,7 @@ case 'rs':
 }
 
 /* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList(IMP::$mailbox);
 $pageOb = $imp_mailbox->buildMailboxPage($vars->p, $vars->s);
 
 /* Generate page title. */
diff --git a/imp/mailbox.php b/imp/mailbox.php
index 4d57ac812..634b3686f 100644
--- a/imp/mailbox.php
+++ b/imp/mailbox.php
@@ -225,7 +225,7 @@ if ($conf['user']['allow_folders']) {
 }
 
 /* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList(IMP::$mailbox);
 $pageOb = $imp_mailbox->buildMailboxPage($vars->page, $start);
 $show_preview = $prefs->getValue('preview_enabled');
 
diff --git a/imp/message-mimp.php b/imp/message-mimp.php
index 328857af9..e82db7e5a 100644
--- a/imp/message-mimp.php
+++ b/imp/message-mimp.php
@@ -29,7 +29,7 @@ Horde_Registry::appInit('imp', array(
 $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));
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 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 9afac4098..78189ba31 100644
--- a/imp/message.php
+++ b/imp/message.php
@@ -34,7 +34,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));
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 if (!$imp_mailbox->isValidIndex()) {
     _returnToMailbox(null, 'message_missing');
     require IMP_BASE . '/mailbox.php';
diff --git a/imp/rss.php b/imp/rss.php
index f81cd809d..6107ce2ab 100644
--- a/imp/rss.php
+++ b/imp/rss.php
@@ -46,7 +46,7 @@ if (!empty($request)) {
     $new_mail = (isset($request_parts[1]) && ($request_parts[1] === 'new'));
 }
 
-$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb($mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList($mailbox);
 $imp_search = $injector->getInstance('IMP_Search');
 
 /* Obtain some information describing the mailbox state. */
diff --git a/imp/thread.php b/imp/thread.php
index 1f5ccf513..ea4e54141 100644
--- a/imp/thread.php
+++ b/imp/thread.php
@@ -28,7 +28,7 @@ $mode = $vars->mode
     : 'thread';
 
 $imp_imap = $injector->getInstance('IMP_Imap')->getOb();
-$imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 
 $error = false;
 if ($mode == 'thread') {
-- 
2.11.0