From 89d955cb34250323027fe31228c410ebee550431 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 17 Jul 2009 13:25:37 -0600 Subject: [PATCH] Remove all Horde::fatal()'s from horde-hatchery --- babel/lib/base.php | 16 ++++++++-------- babel/viewsource.php | 22 +++++++++++----------- chora/lib/base.php | 2 +- crumb/lib/Driver/sql.php | 8 +++----- crumb/lib/base.php | 2 +- fima/lib/base.php | 2 +- folks/lib/Driver/sql.php | 8 ++++---- folks/lib/Friends/sql.php | 6 +++--- folks/lib/base.php | 2 +- framework/Model/lib/Horde/Form.php | 2 +- imp/acl.php | 19 ++++--------------- imp/attachment.php | 10 +++++----- imp/fetchmailprefs.php | 6 +----- imp/filterprefs.php | 6 +----- imp/lib/IMP.php | 7 ++----- imp/lib/base.php | 2 +- imp/pgp.php | 21 ++++----------------- imp/smime.php | 21 ++++----------------- imp/stationery.php | 6 +----- imp/view.php | 22 +++++----------------- ingo/filters.php | 2 +- ingo/lib/Driver/Ldap.php | 4 +++- ingo/lib/Ingo.php | 15 ++++++++------- ingo/lib/Storage/Sql.php | 6 ++++-- ingo/lib/base.php | 2 +- jeta/lib/base.php | 2 +- kastalia/download.php | 2 +- kastalia/lib/base.php | 2 +- kronolith/lib/base.php | 2 +- kronolith/pref_api.php | 6 +----- news/files.php | 22 +++++++--------------- news/lib/Categories.php | 2 +- news/lib/Driver.php | 6 +++--- news/lib/Driver/sql.php | 7 ++++--- news/lib/base.php | 2 +- skoli/lib/base.php | 2 +- skoli/pref_api.php | 6 +----- timeobjects/lib/base.php | 2 +- turba/lib/Object.php | 4 +++- turba/lib/base.php | 2 +- turba/scripts/upgrades/2.1_to_2.2_sql_schema.php | 2 +- turba/view.php | 14 +++++++------- 42 files changed, 115 insertions(+), 189 deletions(-) diff --git a/babel/lib/base.php b/babel/lib/base.php index db363b6db..c68e9b25a 100644 --- a/babel/lib/base.php +++ b/babel/lib/base.php @@ -35,7 +35,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; @@ -65,19 +65,19 @@ $template = new Horde_Template(); /* Module selection */ $app = Horde_Util::getFormData('module'); - + /* Language selection */ if (($lang = Horde_Util::getFormData('display_language')) !== null) { $_SESSION['babel']['language'] = $lang; } elseif (isset($_SESSION['babel']['language'])) { $lang = $_SESSION['babel']['language']; } else { - + $tests = Horde_Nls::$config['languages']; - + // Unset English unset($tests['en_US']); - + foreach($tests as $dir => $desc) { if (!Babel::hasPermission("language:$dir")) { continue; @@ -88,7 +88,7 @@ if (($lang = Horde_Util::getFormData('display_language')) !== null) { } $_SESSION['babel']['language'] = $lang; } - + /* Set up the template fields. */ $template->set('menu', Babel::getMenu('string')); $template->set('notify', Horde_Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status'))); @@ -102,11 +102,11 @@ if ($app) { $template->set('fmenu', $fmenu); if ($lang && !Babel::hasPermission("language:$lang")) { - Horde::fatal(sprintf(_("Access forbidden to '%s'."), $lang), __FILE__, __LINE__, true); + throw new Horde_Exception(sprintf(_("Access forbidden to '%s'."), $lang)); } if ($app && !Babel::hasPermission("module:$app")) { - Horde::fatal(sprintf(_("Access forbidden to '%s'."), $app), __FILE__, __LINE__, true); + throw new Horde_Exception(sprintf(_("Access forbidden to '%s'."), $app)); } /* Custom sort function */ diff --git a/babel/viewsource.php b/babel/viewsource.php index a61a4c487..b62b1bd3c 100644 --- a/babel/viewsource.php +++ b/babel/viewsource.php @@ -22,12 +22,12 @@ if ($app == 'horde') { } if (empty($srcfile)) { - Horde::fatal(_("Missing filename!"), __FILE__, __LINE__, false); + throw new Horde_Exception(_("Missing filename!")); } $rpath = realpath(HORDE_BASE); if (!preg_match(";$rpath;", $srcfile)) { - Horde::fatal(sprintf(_("Access denied to %s"), $srcfile), __FILE__, __LINE__, false); + throw new Horde_Exception(sprintf(_("Access denied to %s"), $srcfile)); } // Get File content @@ -44,38 +44,38 @@ require $registry->get('templates', 'horde') . '/common-footer.inc'; function printCode($code, $sline = 1, $sdiff = 10) { if (!is_array($code)) $code = explode("\n", $code); - + $count_lines = count($code); $r = ''; - + $from = $sline - $sdiff; $to = $sline + $sdiff; - + foreach ($code as $line => $code_line) { - + if ($from && $line < $from) { continue; } - + if ($to && $line > $to) { break; } - + $r1 = ($line + 1); - + if (ereg("<\?(php)?[^[:graph:]]", $code_line)) { $r2 = highlight_string($code_line, 1)."
"; } else { $r2 = ereg_replace("(<\?php )+", "", highlight_string(""; } - + if ($r1 == $sline) { $r .= sprintf('%s %s', $r1, $r2); } else { $r .= sprintf('%s %s', $r1, $r2); } } - + $r = '' . $r . '
'; echo "
".$r."
"; diff --git a/chora/lib/base.php b/chora/lib/base.php index 40c0a0838..23521c316 100644 --- a/chora/lib/base.php +++ b/chora/lib/base.php @@ -37,7 +37,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; define('CHORA_TEMPLATES', $registry->get('templates')); diff --git a/crumb/lib/Driver/sql.php b/crumb/lib/Driver/sql.php index d8a9065e0..bbcbcfd9f 100644 --- a/crumb/lib/Driver/sql.php +++ b/crumb/lib/Driver/sql.php @@ -20,8 +20,6 @@ * The table structure can be created by the scripts/sql/crumb_foo.sql * script. * - * $Horde$ - * * Copyright 2007-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you @@ -96,7 +94,7 @@ class Crumb_Driver_sql extends Crumb_Driver { /** * Attempts to open a persistent connection to the SQL server. * - * @return boolean True on success; exits (Horde::fatal()) on error. + * @return boolean True on success. */ function _connect() { @@ -122,7 +120,7 @@ class Crumb_Driver_sql extends Crumb_Driver { $this->_write_db = &DB::connect($this->_params, array('persistent' => !empty($this->_params['persistent']))); if (is_a($this->_write_db, 'PEAR_Error')) { - Horde::fatal($this->_write_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_write_db); } // Set DB portability options. @@ -140,7 +138,7 @@ class Crumb_Driver_sql extends Crumb_Driver { $this->_db = &DB::connect($params, array('persistent' => !empty($params['persistent']))); if (is_a($this->_db, 'PEAR_Error')) { - Horde::fatal($this->_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_write_db); } // Set DB portability options. diff --git a/crumb/lib/base.php b/crumb/lib/base.php index 6a7a23f2f..4481d3c06 100644 --- a/crumb/lib/base.php +++ b/crumb/lib/base.php @@ -30,7 +30,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; @define('CRUMB_TEMPLATES', $registry->get('templates')); diff --git a/fima/lib/base.php b/fima/lib/base.php index ea8b8e57d..e793a15ec 100644 --- a/fima/lib/base.php +++ b/fima/lib/base.php @@ -33,7 +33,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; @define('FIMA_TEMPLATES', $registry->get('templates')); diff --git a/folks/lib/Driver/sql.php b/folks/lib/Driver/sql.php index 41c254b1d..7c1c519dc 100644 --- a/folks/lib/Driver/sql.php +++ b/folks/lib/Driver/sql.php @@ -557,7 +557,7 @@ class Folks_Driver_sql extends Folks_Driver { /** * Attempts to open a persistent connection to the SQL server. * - * @return boolean True on success; exits (Horde::fatal()) on error. + * @return boolean True on success. */ private function _connect() { @@ -579,7 +579,7 @@ class Folks_Driver_sql extends Folks_Driver { $this->_write_db = DB::connect($this->_params, array('persistent' => !empty($this->_params['persistent']))); if ($this->_write_db instanceof PEAR_Error) { - Horde::fatal($this->_write_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_write_db); } // Set DB portability options. @@ -597,7 +597,7 @@ class Folks_Driver_sql extends Folks_Driver { $this->_db = DB::connect($params, array('persistent' => !empty($params['persistent']))); if ($this->_db instanceof PEAR_Error) { - Horde::fatal($this->_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_db); } // Set DB portability options. @@ -616,4 +616,4 @@ class Folks_Driver_sql extends Folks_Driver { return true; } -} \ No newline at end of file +} diff --git a/folks/lib/Friends/sql.php b/folks/lib/Friends/sql.php index a31ad88fe..fd4d03760 100644 --- a/folks/lib/Friends/sql.php +++ b/folks/lib/Friends/sql.php @@ -196,7 +196,7 @@ class Folks_Friends_sql extends Folks_Friends { /** * Attempts to open a persistent connection to the SQL server. * - * @return boolean True on success; exits (Horde::fatal()) on error. + * @return boolean True on success. */ protected function _connect() { @@ -223,7 +223,7 @@ class Folks_Friends_sql extends Folks_Friends { $this->_write_db = DB::connect($this->_params, array('persistent' => !empty($this->_params['persistent']))); if ($this->_write_db instanceof PEAR_Error) { - Horde::fatal($this->_write_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_write_db); } // Set DB portability options. @@ -241,7 +241,7 @@ class Folks_Friends_sql extends Folks_Friends { $this->_db = DB::connect($params, array('persistent' => !empty($params['persistent']))); if ($this->_db instanceof PEAR_Error) { - Horde::fatal($this->_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_db); } // Set DB portability options. diff --git a/folks/lib/base.php b/folks/lib/base.php index b3d65d87d..e1ca9cd9a 100644 --- a/folks/lib/base.php +++ b/folks/lib/base.php @@ -25,7 +25,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; define('FOLKS_TEMPLATES', $registry->get('templates')); diff --git a/framework/Model/lib/Horde/Form.php b/framework/Model/lib/Horde/Form.php index 89b9f6ccb..4735833f5 100644 --- a/framework/Model/lib/Horde/Form.php +++ b/framework/Model/lib/Horde/Form.php @@ -112,7 +112,7 @@ class Horde_Form { { $type_class = 'Horde_Form_Type_' . $type; if (!class_exists($type_class)) { - Horde::fatal(PEAR::raiseError(sprintf('Nonexistant class "%s" for field type "%s"', $type_class, $type)), __FILE__, __LINE__); + throw new Horde_Exception(sprintf('Nonexistant class "%s" for field type "%s"', $type_class, $type)); } $type_ob = new $type_class(); call_user_func_array(array(&$type_ob, 'init'), $params); diff --git a/imp/acl.php b/imp/acl.php index 4d11959eb..0682a880c 100644 --- a/imp/acl.php +++ b/imp/acl.php @@ -70,11 +70,7 @@ case 'imp_acl_set': } if ($ok_form) { - try { - $current_acl = $ACLDriver->getACL($folder); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $current_acl = $ACLDriver->getACL($folder); foreach ($acls as $user => $acl) { if ($acl) { $acl = array_flip($acl); @@ -126,19 +122,12 @@ if (empty($folder)) { $folder = 'INBOX'; } -try { - $curr_acl = $ACLDriver->getACL($folder); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +$curr_acl = $ACLDriver->getACL($folder); $canEdit = $ACLDriver->canEdit($folder, $_SESSION['imp']['uniquser']); require_once 'Horde/Prefs/UI.php'; -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} + +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/imp/attachment.php b/imp/attachment.php index 7c90c6fb4..e1b6d8754 100644 --- a/imp/attachment.php +++ b/imp/attachment.php @@ -25,7 +25,7 @@ $self_url = Horde::selfUrl(false, true, true); // Lets see if we are even able to send the user an attachment. if (!$conf['compose']['link_attachments']) { - Horde::fatal(_("Linked attachments are forbidden."), $self_url, __LINE__); + throw new Horde_Exception(_("Linked attachments are forbidden.")); } // Gather required form variables. @@ -33,13 +33,13 @@ $mail_user = Horde_Util::getFormData('u'); $time_stamp = Horde_Util::getFormData('t'); $file_name = Horde_Util::getFormData('f'); if (is_null($mail_user) || is_null($time_stamp) || is_null($file_name)) { - Horde::fatal(_("The attachment was not found."), $self_url, __LINE__); + throw new Horde_Exception(_("The attachment was not found.")); } // Initialize the VFS. $vfsroot = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type'])); if (is_a($vfsroot, 'PEAR_Error')) { - Horde::fatal(sprintf(_("Could not create the VFS backend: %s"), $vfsroot->getMessage()), $self_url, __LINE__); + throw new Horde_Exception(sprintf(_("Could not create the VFS backend: %s"), $vfsroot->getMessage())); } // Check if the file exists. @@ -48,7 +48,7 @@ $time_stamp = basename($time_stamp); $file_name = escapeshellcmd(basename($file_name)); $full_path = sprintf(IMP_Compose::VFS_LINK_ATTACH_PATH . '/%s/%d', $mail_user, $time_stamp); if (!$vfsroot->exists($full_path, $file_name)) { - Horde::fatal(_("The specified attachment does not exist. It may have been deleted by the original sender."), $self_url, __LINE__); + throw new Horde_Exception(_("The specified attachment does not exist. It may have been deleted by the original sender.")); } // Check to see if we need to send a verification message. @@ -112,7 +112,7 @@ if ($conf['compose']['link_attachments_notify']) { $file_data = $vfsroot->read($full_path, $file_name); if (is_a($file_data, 'PEAR_Error')) { Horde::logMessage($file_data, __FILE__, __LINE__, PEAR_LOG_ERR); - Horde::fatal(_("The specified file cannot be read."), $self_url, __LINE__); + throw new Horde_Exception(_("The specified file cannot be read.")); } $mime_type = Horde_Mime_Magic::analyzeData($file_data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null); if ($mime_type === false) { diff --git a/imp/fetchmailprefs.php b/imp/fetchmailprefs.php index 7c3573dd3..6eeceb5ba 100644 --- a/imp/fetchmailprefs.php +++ b/imp/fetchmailprefs.php @@ -88,11 +88,7 @@ case 'fetchmail_prefs_delete': } require_once 'Horde/Prefs/UI.php'; -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/imp/filterprefs.php b/imp/filterprefs.php index b54ca6b2c..02a1d713c 100644 --- a/imp/filterprefs.php +++ b/imp/filterprefs.php @@ -12,11 +12,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; require_once 'Horde/Prefs/UI.php'; -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); /* Are preferences locked? */ $login_locked = $prefs->isLocked('filter_on_login') || empty($_SESSION['imp']['filteravail']); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 103aa3961..779e4dae6 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1641,14 +1641,11 @@ class IMP * associated with creating the object. * * @return Horde_Cache A pointer to a Horde_Cache object. + * @throws Horde_Exception */ public static function getCache() { - try { - return Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver'])); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + return Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver'])); } /** diff --git a/imp/lib/base.php b/imp/lib/base.php index 5941794a7..f43f12051 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -66,7 +66,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; if (!defined('IMP_TEMPLATES')) { diff --git a/imp/pgp.php b/imp/pgp.php index 2e1ffeda1..82eca7a6f 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -71,12 +71,7 @@ function _reloadWindow() require_once dirname(__FILE__) . '/lib/base.php'; -try { - $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} - +$imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp')); $secure_check = Horde::isConnectionSecure(); /* Run through the action handlers */ @@ -258,14 +253,10 @@ case 'save_options': case 'save_attachment_public_key': /* Retrieve the key from the message. */ - try { - $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox')); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox')); $mime_part = $contents->getMIMEPart(Horde_Util::getFormData('mime_id')); if (empty($mime_part)) { - Horde::fatal(new Horde_Exception('Cannot retrieve public key from message.')); + throw new Horde_Exception('Cannot retrieve public key from message.'); } /* Add the public key to the storage system. */ @@ -302,11 +293,7 @@ try { $notification->push($e); } -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); require_once 'Horde/Prefs/UI.php'; $app = 'imp'; diff --git a/imp/smime.php b/imp/smime.php index b74b4cbd8..db011bfb5 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -80,12 +80,7 @@ function _printKeyInfo($cert) require_once dirname(__FILE__) . '/lib/base.php'; -try { - $imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} - +$imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime')); $secure_check = Horde::isConnectionSecure(); /* Run through the action handlers */ @@ -178,14 +173,10 @@ case 'process_import_personal_certs': case 'save_attachment_public_key': /* Retrieve the key from the message. */ - try { - $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox')); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox')); $mime_part = $contents->getMIMEPart(Horde_Util::getFormData('mime_id')); if (empty($mime_part)) { - Horde::fatal(new Horde_Exception('Cannot retrieve public key from message.')); + throw new Horde_Exception('Cannot retrieve public key from message.'); } /* Add the public key to the storage system. */ @@ -219,11 +210,7 @@ try { $notification->push($e); } -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); require_once 'Horde/Prefs/UI.php'; $app = 'imp'; diff --git a/imp/stationery.php b/imp/stationery.php index f288f74fd..e05c19de6 100644 --- a/imp/stationery.php +++ b/imp/stationery.php @@ -95,11 +95,7 @@ if ($stationery['t'] == 'html') { /* Show the header. */ require_once 'Horde/Prefs/UI.php'; -try { - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -} catch (Horde_Exception $e) { - Horde::fatal($e); -} +extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); diff --git a/imp/view.php b/imp/view.php index 742afa343..d5c466523 100644 --- a/imp/view.php +++ b/imp/view.php @@ -82,11 +82,7 @@ if ($actionID == 'compose_attach_preview') { exit; } - try { - $contents = IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $contents = IMP_Contents::singleton($uid . IMP::IDX_SEP . $mailbox); } /* Run through action handlers */ @@ -111,12 +107,8 @@ case 'download_all': } if (!empty($tosave)) { - try { - $horde_compress = Horde_Compress::factory('zip'); - $body = $horde_compress->compress($tosave, array('stream' => true)); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $horde_compress = Horde_Compress::factory('zip'); + $body = $horde_compress->compress($tosave, array('stream' => true)); fseek($body, 0, SEEK_END); $browser->downloadHeaders($zipfile, 'application/zip', false, ftell($body)); rewind($body); @@ -135,12 +127,8 @@ case 'download_render': /* Compress output? */ if (Horde_Util::getFormData('zip')) { - try { - $horde_compress = Horde_Compress::factory('zip'); - $body = $horde_compress->compress(array(array('data' => $mime->getContents(), 'name' => $name)), array('stream' => true)); - } catch (Horde_Exception $e) { - Horde::fatal($e); - } + $horde_compress = Horde_Compress::factory('zip'); + $body = $horde_compress->compress(array(array('data' => $mime->getContents(), 'name' => $name)), array('stream' => true)); $name .= '.zip'; $type = 'application/zip'; } else { diff --git a/ingo/filters.php b/ingo/filters.php index 786ec331c..760affa13 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; /* Get the list of filter rules. */ $filters = &$ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS); if (is_a($filters, 'PEAR_Error')) { - Horde::fatal($filters, __FILE__, __LINE__); + throw new Horde_Exception($filters); } /* Load the Ingo_Script:: driver. */ diff --git a/ingo/lib/Driver/Ldap.php b/ingo/lib/Driver/Ldap.php index d6a5ddf31..5986d9c74 100644 --- a/ingo/lib/Driver/Ldap.php +++ b/ingo/lib/Driver/Ldap.php @@ -13,11 +13,13 @@ class Ingo_Driver_Ldap extends Ingo_Driver { /** * Constructor. + * + * @throws Horde_Exception */ public function __construct($params = array()) { if (!Horde_Util::extensionExists('ldap')) { - Horde::fatal(PEAR::raiseError(_("LDAP support is required but the LDAP module is not available or not loaded.")), __FILE__, __LINE__); + throw new Horde_Exception(_("LDAP support is required but the LDAP module is not available or not loaded.")); } $default_params = array( diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 1bf533b5c..9b2f9f20a 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -207,13 +207,13 @@ class Ingo * single value or an array of multiple values. * * @return array The backend entry. - * Calls Horde::fatal() on error. + * @throws Horde_Exception */ static public function getBackend() { include INGO_BASE . '/config/backends.php'; if (!isset($backends) || !is_array($backends)) { - Horde::fatal(PEAR::raiseError(_("No backends configured in backends.php")), __FILE__, __LINE__); + throw new Horde_Exception(_("No backends configured in backends.php")); } $backend = null; @@ -237,16 +237,16 @@ class Ingo /* Check for valid backend configuration. */ if (!isset($backend)) { - Horde::fatal(PEAR::raiseError(_("No backend configured for this host")), __FILE__, __LINE__); + throw new Horde_Exception(_("No backend configured for this host")); } $backends[$backend]['id'] = $name; $backend = $backends[$backend]; if (empty($backend['script'])) { - Horde::fatal(PEAR::raiseError(sprintf(_("No \"%s\" element found in backend configuration."), 'script')), __FILE__, __LINE__); + throw new Horde_Exception(sprintf(_("No \"%s\" element found in backend configuration."), 'script')); } elseif (empty($backend['driver'])) { - Horde::fatal(PEAR::raiseError(sprintf(_("No \"%s\" element found in backend configuration."), 'driver')), __FILE__, __LINE__); + throw new Horde_Exception(sprintf(_("No \"%s\" element found in backend configuration."), 'driver')); } /* Make sure the 'params' entry exists. */ @@ -260,14 +260,15 @@ class Ingo /** * Loads a Ingo_Script:: backend and checks for errors. * - * @return Ingo_Script Script object on success, PEAR_Error on failure. + * @return Ingo_Script Script object on success. + * @throws Horde_Exception */ static public function loadIngoScript() { $ingo_script = Ingo_Script::factory($_SESSION['ingo']['backend']['script'], isset($_SESSION['ingo']['backend']['scriptparams']) ? $_SESSION['ingo']['backend']['scriptparams'] : array()); if (is_a($ingo_script, 'PEAR_Error')) { - Horde::fatal($ingo_script, __FILE__, __LINE__); + throw new Horde_Exception($ingo_script); } return $ingo_script; diff --git a/ingo/lib/Storage/Sql.php b/ingo/lib/Storage/Sql.php index 6b3c45bdf..137fa037b 100644 --- a/ingo/lib/Storage/Sql.php +++ b/ingo/lib/Storage/Sql.php @@ -56,6 +56,8 @@ class Ingo_Storage_Sql extends Ingo_Storage * Constructor. * * @param array $params Additional parameters for the subclass. + * + * @throws Horde_Exception */ public function __construct($params = array()) { @@ -84,7 +86,7 @@ class Ingo_Storage_Sql extends Ingo_Storage array('persistent' => !empty($this->_params['persistent']), 'ssl' => !empty($this->_params['ssl']))); if (is_a($this->_write_db, 'PEAR_Error')) { - Horde::fatal($this->_write_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_write_db); } /* Set DB portability options. */ switch ($this->_write_db->phptype) { @@ -103,7 +105,7 @@ class Ingo_Storage_Sql extends Ingo_Storage array('persistent' => !empty($params['persistent']), 'ssl' => !empty($params['ssl']))); if (is_a($this->_db, 'PEAR_Error')) { - Horde::fatal($this->_db, __FILE__, __LINE__); + throw new Horde_Exception($this->_db); } switch ($this->_db->phptype) { diff --git a/ingo/lib/base.php b/ingo/lib/base.php index 63b913d6c..7b9ed3787 100644 --- a/ingo/lib/base.php +++ b/ingo/lib/base.php @@ -26,7 +26,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; diff --git a/jeta/lib/base.php b/jeta/lib/base.php index 019e8956b..6f855fba4 100644 --- a/jeta/lib/base.php +++ b/jeta/lib/base.php @@ -25,7 +25,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; diff --git a/kastalia/download.php b/kastalia/download.php index 577c37b0a..72ab0f47d 100755 --- a/kastalia/download.php +++ b/kastalia/download.php @@ -37,7 +37,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } //################### ################### diff --git a/kastalia/lib/base.php b/kastalia/lib/base.php index 7827951d5..52e3596ad 100755 --- a/kastalia/lib/base.php +++ b/kastalia/lib/base.php @@ -27,7 +27,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; @define('KASTALIA_TEMPLATES', $registry->get('templates')); diff --git a/kronolith/lib/base.php b/kronolith/lib/base.php index 53fec4901..580311f21 100644 --- a/kronolith/lib/base.php +++ b/kronolith/lib/base.php @@ -34,7 +34,7 @@ try { if ($e->getCode() == 'permission_denied') { Horde::authenticationFailureRedirect(); } - Horde::fatal($e, __FILE__, __LINE__, false); + throw $e; } $conf = &$GLOBALS['conf']; define('KRONOLITH_TEMPLATES', $registry->get('templates')); diff --git a/kronolith/pref_api.php b/kronolith/pref_api.php index 795a75c26..887a76e86 100644 --- a/kronolith/pref_api.php +++ b/kronolith/pref_api.php @@ -34,11 +34,7 @@ require_once $appbase . '/lib/base.php'; $pref = Horde_Util::getFormData('pref'); if (!$pref) { $_prefs = array(); - try { - extract(Horde::loadConfiguration('prefs.php', array('_prefs'), $app)); - } catch (Horde_Exception $e) { - Horde::fatal($e, __FILE__, __LINE__); - } + extract(Horde::loadConfiguration('prefs.php', array('_prefs'), $app)); echo '