Expire cache when upgrading IMP
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 10 Sep 2010 21:29:57 +0000 (15:29 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 10 Sep 2010 22:51:43 +0000 (16:51 -0600)
imp/lib/LoginTasks/SystemTask/UpgradeFromImp4.php

index 205f33a..684c348 100644 (file)
@@ -27,6 +27,7 @@ class IMP_LoginTasks_SystemTask_UpgradeFromImp4 extends Horde_LoginTasks_SystemT
     public function execute()
     {
         $this->_upgradeAbookPrefs();
+        $this->_upgradeExpireImapCache();
         $this->_upgradeForwardPrefs();
         $this->_upgradeLoginTasksPrefs();
         $this->_upgradeSortPrefs();
@@ -67,6 +68,23 @@ class IMP_LoginTasks_SystemTask_UpgradeFromImp4 extends Horde_LoginTasks_SystemT
     }
 
     /**
+     * Expire existing IMAP cache.
+     */
+    protected function _upgradeExpireImapCache()
+    {
+        try {
+            $ob = $injector->getInstance('IMP_Imap')->getOb()->ob;
+            $ob->login();
+
+            $mboxes = $ob->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array('flat' => true));
+
+            foreach ($mboxes as $val) {
+                $ob->cache->deleteMailbox($val);
+            }
+        } catch (Exception $e) {}
+    }
+
+    /**
      * Upgrade to the new forward preferences.
      */
     protected function _upgradeForwardPrefs()