From: Michael M Slusarz Date: Tue, 18 Nov 2008 22:38:39 +0000 (-0700) Subject: Use exception logging callback. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=aca7bb3e20f1f59452f00a15d4f951dedf8543ef;p=horde.git Use exception logging callback. --- diff --git a/imp/lib/Auth/imp.php b/imp/lib/Auth/imp.php index 85a2b22c4..1fc084391 100644 --- a/imp/lib/Auth/imp.php +++ b/imp/lib/Auth/imp.php @@ -63,7 +63,6 @@ class Auth_imp extends Auth $imp_imap->ob->login(); return true; } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); IMP::loginLogMessage('failed', __FILE__, __LINE__); $this->_setAuthError(AUTH_REASON_BADLOGIN); return false; diff --git a/imp/lib/Fetchmail.php b/imp/lib/Fetchmail.php index 72b239afc..8a85e57a9 100644 --- a/imp/lib/Fetchmail.php +++ b/imp/lib/Fetchmail.php @@ -265,7 +265,6 @@ abstract class IMP_Fetchmail $GLOBALS['imp_imap']->ob->append($this->_params['lmailbox'], array(array('data' => $msg))); return true; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return false; } } diff --git a/imp/lib/Fetchmail/imap.php b/imp/lib/Fetchmail/imap.php index 524c7c03d..12abc6fff 100644 --- a/imp/lib/Fetchmail/imap.php +++ b/imp/lib/Fetchmail/imap.php @@ -99,7 +99,6 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail $res = $this->_ob->listMailboxes($mbox, array('flat' => true)); return (bool)count($res); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return false; } } @@ -130,7 +129,6 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail $this->_ob = Horde_Imap_Client::getInstance(($protocol == 'imap') ? 'Socket' : 'Cclient-pop3', $imap_config); return true; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return PEAR::raiseError(_("Cannot connect to the remote mail server: ") . $e->getMessage()); } } @@ -173,7 +171,6 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail ), array('ids' => $search_res['match'])); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return 0; } @@ -191,7 +188,6 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail ), array('ids' => array($this->_index))); $mail_source = $this->_processMailMessage($res[$this->_index]['headertext'][0], $res[$this->_index]['bodytext'][0]); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); continue; } @@ -218,9 +214,7 @@ class IMP_Fetchmail_imap extends IMP_Fetchmail if ($this->_params['del']) { $imp_imap->ob->expunge($mbox, array('ids' => $to_store)); } - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } return $numMsgs; diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 39f89d64f..c85364194 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -195,7 +195,6 @@ class IMP_Folder $notification->push(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), 'horde.success'); $deleted[] = $folder; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); //$notification->push(sprintf(_("The folder \"%s\" was not deleted. This is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); } } @@ -274,7 +273,6 @@ class IMP_Folder try { $GLOBALS['imp_imap']->ob->createMailbox($folder); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); //$notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), $display_folder) . ': ' . imap_last_error(), 'horde.error'); return false; } @@ -315,7 +313,6 @@ class IMP_Folder $ret = $GLOBALS['imp_imap']->ob->listMailboxes($folder, array('flat' => true)); return !empty($ret); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return false; } } @@ -357,7 +354,6 @@ class IMP_Folder try { $GLOBALS['imp_imap']->ob->renameMailbox($old, $new); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); //$GLOBALS['notification']->push(sprintf(_("Renaming \"%s\" to \"%s\" failed. This is what the server said"), IMP::displayFolder($old), IMP::displayFolder($new)) . ': ' . imap_last_error(), 'horde.error'); return false; } @@ -404,7 +400,6 @@ class IMP_Folder $notification->push(sprintf(_("You were successfully subscribed to \"%s\""), IMP::displayFolder($folder)), 'horde.success'); $subscribed[] = $folder; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); //$notification->push(sprintf(_("You were not subscribed to \"%s\". Here is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); $return_value = false; } @@ -451,7 +446,6 @@ class IMP_Folder $notification->push(sprintf(_("You were successfully unsubscribed from \"%s\""), IMP::displayFolder($folder)), 'horde.success'); $unsubscribed[] = $folder; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); //$notification->push(sprintf(_("You were not unsubscribed from \"%s\". Here is what the server said"), IMP::displayFolder($folder)) . ': ' . imap_last_error(), 'horde.error'); $return_value = false; } @@ -496,7 +490,6 @@ class IMP_Folder try { $status = $GLOBALS['imp_imap']->status($folder, Horde_Imap_Client::STATUS_MESSAGES); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); continue; } for ($i = 1; $i <= $status['messages']; ++$i) { @@ -510,7 +503,6 @@ class IMP_Folder ), array('ids' => array($i), 'sequence' => true)); $ptr = reset($res); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); continue; } @@ -556,9 +548,7 @@ class IMP_Folder try { $GLOBALS['imp_imap']->ob->append($mbox, array(array('data' => $message))); ++$msgcount; - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } $message = ''; } else { @@ -571,9 +561,7 @@ class IMP_Folder try { $GLOBALS['imp_imap']->ob->append($mbox, array(array('data' => $message))); ++$msgcount; - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } return $msgcount ? $msgcount : false; diff --git a/imp/lib/IMAP.php b/imp/lib/IMAP.php index b8587e28a..04fdba865 100644 --- a/imp/lib/IMAP.php +++ b/imp/lib/IMAP.php @@ -42,6 +42,15 @@ class IMP_IMAP protected $_nsdefault; /** + * Constructor. + */ + function __construct() + { + /* Register the logging callback. */ + Horde_Imap_Client_Exception::$logCallback = array($this, 'logException'); + } + + /** * Save the Horde_Imap_Client object on session shutdown. */ function __destruct() @@ -170,7 +179,6 @@ class IMP_IMAP try { $ob = Horde_Imap_Client::getInstance(($protocol == 'imap') ? 'Socket' : 'Cclient-pop3', $imap_config); } catch (Horde_Imap_Client_Exception $e) { - $this->logException($e); return false; } @@ -229,7 +237,8 @@ class IMP_IMAP */ public function logException($e) { - // @todo + // TODO - Clean this up a bit. + Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); } /** @@ -243,7 +252,6 @@ class IMP_IMAP $this->loadImapObject(); return $GLOBALS['imp_imap']->ob->getNamespaces(!empty($_SESSION['imp']['imap_ext']['namespace']) ? $_SESSION['imp']['imap_ext']['namespace'] : array()); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); // @todo Error handling return array(); } diff --git a/imp/lib/IMAP/Tree.php b/imp/lib/IMAP/Tree.php index 643a00f06..86571a2bb 100644 --- a/imp/lib/IMAP/Tree.php +++ b/imp/lib/IMAP/Tree.php @@ -294,9 +294,7 @@ class IMP_Tree } else { $this->_subscribed = $names; } - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } return $names; @@ -1328,7 +1326,6 @@ class IMP_Tree try { return $GLOBALS['imp_imap']->ob->status($name, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return array(); } } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 49c91092a..86c8ff295 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1119,9 +1119,7 @@ class IMP $ob['limit'] = true; $ob['by'] = Horde_Imap_Client::SORT_ARRIVAL; } - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } if (!$ob['limit'] && diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index fb93f48af..c470b1578 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -179,9 +179,7 @@ class IMP_Mailbox if ($cacheob) { try { $preview_info = $cacheob->get($mbox, array_keys($ids), array('IMPpreview', 'IMPpreviewc')); - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } } @@ -221,9 +219,7 @@ class IMP_Mailbox if (!is_null($cacheob) && !empty($tostore)) { $cacheob->set($mbox, $tostore); } - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } /* Sort via the sorted array index. */ @@ -271,7 +267,6 @@ class IMP_Mailbox $res = $GLOBALS['imp_imap']->ob->search($this->_mailbox, $query, array('sort' => array($sortpref['by']), 'reverse' => (bool)$sortpref['dir'])); $this->_sorted = $res['sort']; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); $this->_sorted = array(); } } @@ -331,7 +326,6 @@ class IMP_Mailbox $status_res = $GLOBALS['imp_imap']->ob->status($this->_mailbox, $type == 'recent' ? Horde_Imap_Client::STATUS_RECENT : Horde_Imap_Client::STATUS_UNSEEN); return $status_res[$type]; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return 0; } } @@ -350,7 +344,6 @@ class IMP_Mailbox $res = $GLOBALS['imp_imap']->ob->search($this->_mailbox, $criteria, array('results' => $results)); return $count ? $res['count'] : $res['match']; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return $count ? 0 : array(); } } @@ -530,7 +523,6 @@ class IMP_Mailbox $status = $GLOBALS['imp_imap']->ob->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES); $ret['anymsg'] = (bool)$status['messages']; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); $ret['anymsg'] = false; } } @@ -582,7 +574,6 @@ class IMP_Mailbox try { $this->_threadob = $GLOBALS['imp_imap']->ob->thread($this->_mailbox); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return new Horde_Imap_Client_Thread(); } } @@ -735,7 +726,6 @@ class IMP_Mailbox $ret = $GLOBALS['imp_imap']->ob->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_UIDNEXT | Horde_Imap_Client::STATUS_UIDVALIDITY); return implode('|', array($ret['messages'], $ret['uidnext'], $ret['uidvalidity'], $sortpref['by'], $sortpref['dir'])); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return ''; } } diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 3bac335c9..914839ea9 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -137,7 +137,6 @@ class IMP_Message try { $imp_imap->ob->copy($folder, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move)); } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); //$notification->push(sprintf($message, IMP::displayFolder($folder), IMP::displayFolder($targetMbox)) . ': ' . imap_last_error(), 'horde.error'); $return_value = false; } @@ -206,7 +205,6 @@ class IMP_Message try { $imp_imap->ob->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true)); } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); // @todo Check for overquota error. return false; } @@ -217,9 +215,7 @@ class IMP_Message if ($maillog_update) { try { $fetch = $imp_imap->ob->fetch($mbox, array(Horde_Imap_Client::FETCH_ENVELOPE => true), array('ids' => $msgIndices)); - } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } /* Delete the messages. */ @@ -246,9 +242,7 @@ class IMP_Message if ($expunge_now) { $this->expungeMailbox($indices_array); } - } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} /* Get the list of Message-IDs deleted, and remove * the information from the mail log. */ @@ -505,7 +499,6 @@ class IMP_Message $uid = $GLOBALS['imp_imap']->ob->append($folder, array(array('data' => $res['headertext'][0] . $contents->toString($message, true), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id']))); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return PEAR::raiseError(_("An error occured while attempting to strip the attachment.")); } @@ -555,7 +548,6 @@ class IMP_Message try { $imp_imap->ob->store($mbox, array_merge($action_array, array('ids' => $msgIndices))); } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); $notification->push(sprintf(_("There was an error flagging messages in the folder \"%s\". This is what the server said"), IMP::displayFolder($mbox)) . ': ' . imap_last_error(), 'horde.error'); return false; } @@ -593,7 +585,6 @@ class IMP_Message try { $imp_imap->ob->store($val, $action_array); } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); return false; } } @@ -639,9 +630,7 @@ class IMP_Message try { $imp_imap->ob->expunge($key, array('ids' => is_array($val) ? $val : array())); $update_list[$key] = $val; - } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } return $update_list; @@ -691,9 +680,7 @@ class IMP_Message } $notification->push(sprintf(_("Emptied all messages from %s."), $display_mbox), 'horde.success'); - } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } } @@ -720,7 +707,6 @@ class IMP_Message ? sprintf(_("%.2fMB"), $size / (1024 * 1024)) : $size; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return 0; } } diff --git a/imp/lib/Mime/Viewer/pkcs7.php b/imp/lib/Mime/Viewer/pkcs7.php index 168a048e4..96f590e6f 100644 --- a/imp/lib/Mime/Viewer/pkcs7.php +++ b/imp/lib/Mime/Viewer/pkcs7.php @@ -1,7 +1,4 @@ $quota['storage']['usage'] * 1024, 'limit' => $quota['storage']['limit'] * 1024); } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return PEAR::raiseError(_("Unable to retrieve quota"), 'horde.error'); } } diff --git a/imp/lib/Search.php b/imp/lib/Search.php index bccdc41e4..84027c569 100644 --- a/imp/lib/Search.php +++ b/imp/lib/Search.php @@ -142,9 +142,7 @@ class IMP_Search foreach ($results['sort'] as $val2) { $sorted[] = $val2 . IMP::IDX_SEP . $val; } - } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); - } + } catch (Horde_Imap_Client_Exception $e) {} } return $sorted; @@ -169,7 +167,6 @@ class IMP_Search $results = $GLOBALS['imp_imap']->ob->search($mailbox, $query, array('reverse' => $sortdir, 'sort' => array($sortby))); return $results['sort']; } catch (Horde_Imap_Client_Exception $e) { - $GLOBALS['imp_imap']->logException($e); return array(); } } diff --git a/imp/message.php b/imp/message.php index de2f83c81..3fcfb25d1 100644 --- a/imp/message.php +++ b/imp/message.php @@ -230,7 +230,6 @@ try { Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $readonly)) ), array('ids' => array($index))); } catch (Horde_Imap_Client_Exception $e) { - $imp_imap->logException($e); require IMP_BASE . '/mailbox.php'; exit; }