Bug #8447: Undefined values in login tasks
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 3 Aug 2009 17:55:49 +0000 (11:55 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 3 Aug 2009 17:57:07 +0000 (11:57 -0600)
I think the issue is that these objects are being serialized between
sessions - thus, when unserialized on the next page, initialize() may
not have been called yet.  So we need to put the initialize() calls in
each function that requires a full IMP environment.

imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php
imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php
imp/lib/LoginTasks/Task/PurgeSentmail.php
imp/lib/LoginTasks/Task/PurgeSpam.php
imp/lib/LoginTasks/Task/PurgeTrash.php
imp/lib/LoginTasks/Task/RenameSentmailMonthly.php

index ba97c37..50802a4 100644 (file)
@@ -15,8 +15,6 @@ class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('delete_attachments_monthly');
         if ($this->active &&
             $GLOBALS['prefs']->isLocked('delete_attachments_monthly')) {
@@ -31,6 +29,8 @@ class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         /* Find the UNIX timestamp of the last second that we will not
          * purge. */
         $del_time = gmmktime(0, 0, 0, date('n') - $GLOBALS['prefs']->getValue('delete_attachments_monthly_keep'), 1, date('Y'));
index 27715d9..a2ac053 100644 (file)
@@ -17,8 +17,6 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('delete_sentmail_monthly');
         if ($this->active &&
             $GLOBALS['prefs']->isLocked('delete_sentmail_monthly')) {
@@ -33,6 +31,8 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         /* Get list of all folders, parse through and get the list of all
            old sent-mail folders. Then sort this array according to
            the date. */
index 01d9394..01aafea 100644 (file)
@@ -18,8 +18,6 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('purge_sentmail');
         if ($this->active) {
             $this->interval = $GLOBALS['prefs']->getValue('purge_sentmail_interval');
@@ -37,6 +35,8 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         $imp_folder = IMP_Folder::singleton();
         $imp_message = IMP_Message::singleton();
 
@@ -84,6 +84,8 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task
      */
     public function describe()
     {
+        IMP::initialize();
+
         $mbox_list = array_map(array('IMP', 'displayFolder'), $this->_getFolders());
 
         return sprintf(_("All messages in the folder(s) \"%s\" older than %s days will be permanently deleted."),
index 3a60685..b7428c9 100644 (file)
@@ -18,8 +18,6 @@ class IMP_LoginTasks_Task_PurgeSpam extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('purge_spam');
         if ($this->active) {
             $this->interval = $GLOBALS['prefs']->getValue('purge_spam_interval');
@@ -36,6 +34,8 @@ class IMP_LoginTasks_Task_PurgeSpam extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         /* If there is no Spam folder set, just return. */
         $spam_folder = IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true);
         if (!$spam_folder) {
@@ -79,6 +79,8 @@ class IMP_LoginTasks_Task_PurgeSpam extends Horde_LoginTasks_Task
      */
     public function describe()
     {
+        IMP::initialize();
+
         return sprintf(_("All messages in your \"%s\" folder older than %s days will be permanently deleted."),
                        IMP::displayFolder(IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true)),
                        $GLOBALS['prefs']->getValue('purge_spam_keep'));
index 00f8f89..4346d52 100644 (file)
@@ -17,8 +17,6 @@ class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('purge_trash');
         if ($this->active) {
             $this->interval = $GLOBALS['prefs']->getValue('purge_trash_interval');
@@ -35,6 +33,8 @@ class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         /* If we aren't using a Trash folder or if there is no Trash
            folder set, just return. */
         $trash_folder = IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true);
@@ -79,6 +79,8 @@ class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task
      */
     public function describe()
     {
+        IMP::initialize();
+
         return sprintf(_("All messages in your \"%s\" folder older than %s days will be permanently deleted."),
                        IMP::displayFolder(IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true)),
                        $GLOBALS['prefs']->getValue('purge_trash_keep'));
index b62572d..47e243e 100644 (file)
@@ -17,8 +17,6 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task
      */
     public function __construct()
     {
-        IMP::initialize();
-
         $this->active = $GLOBALS['prefs']->getValue('rename_sentmail_monthly');
         if ($this->active &&
             $GLOBALS['prefs']->isLocked('rename_sentmail_monthly')) {
@@ -33,6 +31,8 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task
      */
     public function execute()
     {
+        IMP::initialize();
+
         $success = true;
 
         $identity = Identity::singleton(array('imp', 'imp'));
@@ -66,6 +66,8 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task
      */
     public function describe()
     {
+        IMP::initialize();
+
         $identity = Identity::singleton(array('imp', 'imp'));
 
         $new_folders = $old_folders = array();