From fd8b4a72f65f3784a246ebfdae1eb63195c7c3ba Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 5 Dec 2013 12:32:32 +0000 Subject: [PATCH] Try to catch exceptions from none existing account --- mail/inc/class.mail_bo.inc.php | 4 ++-- mail/inc/class.mail_hooks.inc.php | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/mail/inc/class.mail_bo.inc.php b/mail/inc/class.mail_bo.inc.php index cd4ccc3358..b0bc1f0111 100644 --- a/mail/inc/class.mail_bo.inc.php +++ b/mail/inc/class.mail_bo.inc.php @@ -170,7 +170,7 @@ class mail_bo * not matching the input profileID, if we can not find a profile matching the given ID * @return mail_bo */ - public static function getInstance($_restoreSession=true, $_profileID=0, $_validate=true) + public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true) { //$_restoreSession=false; //error_log(__METHOD__.__LINE__.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace()); @@ -261,7 +261,7 @@ class mail_bo } if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); } - catch (egw_exception_not_found $e) { + catch (Exception $e) { unset($e); if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!"); } diff --git a/mail/inc/class.mail_hooks.inc.php b/mail/inc/class.mail_hooks.inc.php index 568f326655..7670a24029 100644 --- a/mail/inc/class.mail_hooks.inc.php +++ b/mail/inc/class.mail_hooks.inc.php @@ -119,9 +119,15 @@ class mail_hooks $profileID = 0; if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; + try + { + $mail_bo = mail_bo::getInstance(true,$profileID); + $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; + } catch (Exception $ex) { + error_log(__METHOD__."()" . $ex->getMessage()); + $profileID = null; + } - $mail_bo = mail_bo::getInstance(true,$profileID); - $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; if($profileID && $mail_bo->openConnection($profileID)) { $folderObjects = $mail_bo->getFolderObjects(true, false); foreach($folderObjects as $folderName => $folderInfo) { @@ -732,9 +738,15 @@ class mail_hooks $profileID = 0; if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; + try + { + $mail_bo = mail_bo::getInstance(true,$profileID); + $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; + } catch (Exception $ex) { + error_log(__METHOD__."()" . $ex->getMessage()); + $profileID = null; + } - $mail_bo = mail_bo::getInstance(true,$profileID); - $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; $preferences =& $mail_bo->mailPreferences; $serverCounter = $sieveEnabledServerCounter = 0; if (count($preferences->ic_server)) {