Use exception logging callback.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 18 Nov 2008 22:38:39 +0000 (15:38 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 18 Nov 2008 22:38:39 +0000 (15:38 -0700)
13 files changed:
imp/lib/Auth/imp.php
imp/lib/Fetchmail.php
imp/lib/Fetchmail/imap.php
imp/lib/Folder.php
imp/lib/IMAP.php
imp/lib/IMAP/Tree.php
imp/lib/IMP.php
imp/lib/Mailbox.php
imp/lib/Message.php
imp/lib/Mime/Viewer/pkcs7.php
imp/lib/Quota/imap.php
imp/lib/Search.php
imp/message.php

index 85a2b22..1fc0843 100644 (file)
@@ -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;
index 72b239a..8a85e57 100644 (file)
@@ -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;
         }
     }
index 524c7c0..12abc6f 100644 (file)
@@ -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;
index 39f89d6..c853641 100644 (file)
@@ -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;
index b8587e2..04fdba8 100644 (file)
@@ -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();
         }
index 643a00f..86571a2 100644 (file)
@@ -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();
         }
     }
index 49c9109..86c8ff2 100644 (file)
@@ -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'] &&
index fb93f48..c470b15 100644 (file)
@@ -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 '';
         }
     }
index 3bac335..914839e 100644 (file)
@@ -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;
         }
     }
index 168a048..96f590e 100644 (file)
@@ -1,7 +1,4 @@
 <?php
-
-require_once IMP_BASE . '/lib/Crypt/SMIME.php';
-
 /**
  * The IMP_Horde_Mime_Viewer_pkcs7 class allows viewing/decrypting of S/MIME
  * messages.
index 5166163..559dee9 100644 (file)
@@ -27,7 +27,6 @@ class IMP_Quota_imap extends IMP_Quota
             $quota_val = reset($quota);
             return array('usage' => $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');
         }
     }
index bccdc41..84027c5 100644 (file)
@@ -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();
         }
     }
index de2f83c..3fcfb25 100644 (file)
@@ -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;
 }