From 567afd9432a3914ceec131f1a31c3b0e7c3809bf Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 3 Aug 2009 11:55:49 -0600 Subject: [PATCH] Bug #8447: Undefined values in login tasks 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 | 4 ++-- imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php | 4 ++-- imp/lib/LoginTasks/Task/PurgeSentmail.php | 6 ++++-- imp/lib/LoginTasks/Task/PurgeSpam.php | 6 ++++-- imp/lib/LoginTasks/Task/PurgeTrash.php | 6 ++++-- imp/lib/LoginTasks/Task/RenameSentmailMonthly.php | 6 ++++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php index ba97c371a..50802a4ac 100644 --- a/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php @@ -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')); diff --git a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index 27715d9c8..a2ac05376 100644 --- a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -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. */ diff --git a/imp/lib/LoginTasks/Task/PurgeSentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php index 01d939493..01aafea8a 100644 --- a/imp/lib/LoginTasks/Task/PurgeSentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -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."), diff --git a/imp/lib/LoginTasks/Task/PurgeSpam.php b/imp/lib/LoginTasks/Task/PurgeSpam.php index 3a6068553..b7428c908 100644 --- a/imp/lib/LoginTasks/Task/PurgeSpam.php +++ b/imp/lib/LoginTasks/Task/PurgeSpam.php @@ -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')); diff --git a/imp/lib/LoginTasks/Task/PurgeTrash.php b/imp/lib/LoginTasks/Task/PurgeTrash.php index 00f8f8955..4346d5260 100644 --- a/imp/lib/LoginTasks/Task/PurgeTrash.php +++ b/imp/lib/LoginTasks/Task/PurgeTrash.php @@ -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')); diff --git a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php index b62572db6..47e243e8d 100644 --- a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php @@ -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(); -- 2.11.0