From d97c6693f0f85ac073a9e0bc975ea916bae5f333 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 25 Jan 2011 14:47:19 -0700 Subject: [PATCH] More correct way to report chora errors Can't call Chora::fatal() from init() since it may be called during Horde initialization. --- chora/annotate.php | 6 +++++- chora/browsedir.php | 6 +++++- chora/browsefile.php | 6 +++++- chora/co.php | 6 +++++- chora/commit.php | 6 +++++- chora/cvsgraph.php | 6 +++++- chora/diff.php | 6 +++++- chora/history.php | 6 +++++- chora/lib/Application.php | 3 --- chora/lib/Chora.php | 13 +++++++------ chora/patchsets.php | 6 +++++- chora/stats.php | 6 +++++- 12 files changed, 57 insertions(+), 19 deletions(-) diff --git a/chora/annotate.php b/chora/annotate.php index 74b634bef..d3aa5a9d4 100644 --- a/chora/annotate.php +++ b/chora/annotate.php @@ -10,7 +10,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} /* Spawn the file object. */ try { diff --git a/chora/browsedir.php b/chora/browsedir.php index d6483e78c..09c5dfbe3 100644 --- a/chora/browsedir.php +++ b/chora/browsedir.php @@ -11,7 +11,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} if (!$atdir) { require CHORA_BASE . '/browsefile.php'; diff --git a/chora/browsefile.php b/chora/browsefile.php index 87f964580..da3e4a9c7 100644 --- a/chora/browsefile.php +++ b/chora/browsefile.php @@ -13,7 +13,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} if ($atdir) { require CHORA_BASE . '/browsedir.php'; diff --git a/chora/co.php b/chora/co.php index e475ddd28..8ff009e60 100644 --- a/chora/co.php +++ b/chora/co.php @@ -10,7 +10,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} /* If we know we're at a directory, just go to browsedir.php. */ if ($atdir) { diff --git a/chora/commit.php b/chora/commit.php index e30e64ca2..ebfea7e74 100644 --- a/chora/commit.php +++ b/chora/commit.php @@ -14,7 +14,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} // Exit if patchset feature is not available. if (!$GLOBALS['VC']->hasFeature('patchsets')) { diff --git a/chora/cvsgraph.php b/chora/cvsgraph.php index 31334f3b6..6e1bef596 100644 --- a/chora/cvsgraph.php +++ b/chora/cvsgraph.php @@ -13,7 +13,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} // Exit if cvsgraph isn't active or it's not supported. if (empty($conf['paths']['cvsgraph']) || !$VC->hasFeature('branches')) { diff --git a/chora/diff.php b/chora/diff.php index 934e1a93c..287434716 100644 --- a/chora/diff.php +++ b/chora/diff.php @@ -10,7 +10,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} /* Spawn the repository and file objects */ try { diff --git a/chora/history.php b/chora/history.php index eb3dc2995..cbaa9544d 100644 --- a/chora/history.php +++ b/chora/history.php @@ -10,7 +10,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} // TODO - This currently doesn't work. Chora::fatal('History display is currently broken', '500 Internal Server Error'); diff --git a/chora/lib/Application.php b/chora/lib/Application.php index 84de3613c..c9433001d 100644 --- a/chora/lib/Application.php +++ b/chora/lib/Application.php @@ -216,9 +216,6 @@ class Chora_Application extends Horde_Registry_Application public function sidebarCreate(Horde_Tree_Base $tree, $parent = null, array $params = array()) { - define('CHORA_ERROR_HANDLER', true); - - $arr = array(); asort($GLOBALS['sourceroots']); foreach ($GLOBALS['sourceroots'] as $key => $val) { diff --git a/chora/lib/Chora.php b/chora/lib/Chora.php index 99aa01d62..cc9c0e368 100644 --- a/chora/lib/Chora.php +++ b/chora/lib/Chora.php @@ -76,9 +76,7 @@ class Chora */ static public function fatal($message, $code = null) { - if (defined('CHORA_ERROR_HANDLER') && constant('CHORA_ERROR_HANDLER')) { - return; - } + global $notification, $registry; if (is_a($message, 'Horde_Vcs_Exception')) { $message = $message->getMessage(); @@ -88,10 +86,13 @@ class Chora header('HTTP/1.0 ' . $code); } - $GLOBALS['notification']->push($message, 'horde.error'); - require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc'; + // Make sure we are in Chora scope. + $registry->pushApp('chora'); + + $notification->push($message, 'horde.error'); + require $registry->get('templates', 'horde') . '/common-header.inc'; require CHORA_TEMPLATES . '/menu.inc'; - require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'; + require $registry->get('templates', 'horde') . '/common-footer.inc'; exit; } diff --git a/chora/patchsets.php b/chora/patchsets.php index 3493e3dcd..21b6446ab 100644 --- a/chora/patchsets.php +++ b/chora/patchsets.php @@ -14,7 +14,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} // Exit if patchset feature is not available. if (!$GLOBALS['VC']->hasFeature('patchsets')) { diff --git a/chora/stats.php b/chora/stats.php index 5535558d2..52edfff30 100644 --- a/chora/stats.php +++ b/chora/stats.php @@ -12,7 +12,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('chora'); +try { + Horde_Registry::appInit('chora'); +} catch (Exception $e) { + Chora::fatal($e); +} try { $fl = $VC->getFileObject($where); -- 2.11.0