From b186ce2cacc6da511a2cb5a1f696f12cb097c51e Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 27 Apr 2015 17:53:17 +0200 Subject: [PATCH] Handle non-existed downtime ids with exceptions refs #8902 --- .../application/controllers/DowntimeController.php | 7 ++++--- .../controllers/DowntimesController.php | 6 ++++++ .../application/views/scripts/downtime/show.phtml | 14 ++++---------- .../application/views/scripts/downtimes/show.phtml | 5 ----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 37f466807..26a88ae3b 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -54,6 +54,10 @@ class Monitoring_DowntimeController extends Controller 'service_display_name' ))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow(); + if (false === $this->downtime) { + throw new Zend_Controller_Action_Exception($this->translate('Downtime not found')); + } + if (isset($this->downtime->service_description)) { $this->isService = true; } else { @@ -76,9 +80,6 @@ class Monitoring_DowntimeController extends Controller public function showAction() { - if (false === $this->downtime) { - return; - } $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; $this->view->stateName = isset($this->downtime->service_description) ? diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index eec408110..fe4e9f5bb 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -58,6 +58,12 @@ class Monitoring_DowntimesController extends Controller 'host_display_name', 'service_display_name' ))->addFilter($this->filter)->getQuery()->fetchAll(); + if (false === $this->downtimes) { + throw new Zend_Controller_Action_Exception( + $this->translate('Downtime not found') + ); + } + $this->getTabs() ->add( 'downtimes', diff --git a/modules/monitoring/application/views/scripts/downtime/show.phtml b/modules/monitoring/application/views/scripts/downtime/show.phtml index ade9495b0..6ecc11a7b 100644 --- a/modules/monitoring/application/views/scripts/downtime/show.phtml +++ b/modules/monitoring/application/views/scripts/downtime/show.phtml @@ -1,13 +1,7 @@ -
- - translate('No scheduled downtime matching the filter.') ?> -
- - - - compact): ?> - tabs; ?> - +
+ compact): ?> + tabs; ?> + diff --git a/modules/monitoring/application/views/scripts/downtimes/show.phtml b/modules/monitoring/application/views/scripts/downtimes/show.phtml index c7ddb0ae6..caff167f2 100644 --- a/modules/monitoring/application/views/scripts/downtimes/show.phtml +++ b/modules/monitoring/application/views/scripts/downtimes/show.phtml @@ -1,9 +1,4 @@
- - translate('No scheduled downtimes matching the filter.') ?> -
- - compact): ?> tabs; ?>