Revert "Add proper respond http codes to service and host controller"

This reverts commit 6df031dc78.

I revert this commit for the following reasons:
- MissingParameterException must not be thrown manually because we have UrlParams::getRequired() which was UrlParams::req() before.
- The commit introduces the untranslated string 'host or service'.
- 4xx are client, not server errors.
- Copy and paste code for the stack trace handling in the ErrorController.

refs #6281
This commit is contained in:
Eric Lippmann 2015-05-20 10:31:58 +02:00
parent 902c00e836
commit ce9110d22d
3 changed files with 3 additions and 29 deletions

View File

@ -34,11 +34,7 @@ class ErrorController extends ActionController
$path = preg_split('~/~', $path);
$path = array_shift($path);
$this->getResponse()->setHttpResponseCode(404);
$title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage());
$this->view->title = 'Server error: ' . $title;
if ($this->getInvokeArg('displayExceptions')) {
$this->view->stackTrace = $exception->getTraceAsString();
}
$this->view->message = $this->translate('Page not found.');
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
$this->view->message .= ' ' . sprintf(
$this->translate('Enabling the "%s" module might help!'),

View File

@ -1,7 +1,6 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Exception\MissingParameterException;
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
@ -27,22 +26,12 @@ class Monitoring_HostController extends MonitoredObjectController
*/
public function init()
{
if ($this->params->get('host') === null) {
throw new MissingParameterException(
$this->translate('Required parameter \'%s\' is missing'),
'host'
);
}
$host = new Host($this->backend, $this->params->get('host'));
$this->applyRestriction('monitoring/hosts/filter', $host);
if ($host->fetch() === false) {
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')),
404
);
throw new Zend_Controller_Action_Exception($this->translate('Host not found'));
}
$this->object = $host;
$this->createTabs();

View File

@ -1,7 +1,6 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
use Icinga\Exception\MissingParameterException;
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
@ -27,22 +26,12 @@ class Monitoring_ServiceController extends MonitoredObjectController
*/
public function init()
{
if ($this->params->get('host') === null || $this->params->get('service') === null) {
throw new MissingParameterException(
$this->translate('One of the required parameters \'%s\' is missing'),
'host or service'
);
}
$service = new Service($this->backend, $this->params->get('host'), $this->params->get('service'));
$this->applyRestriction('monitoring/services/filter', $service);
if ($service->fetch() === false) {
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')),
404
);
throw new Zend_Controller_Action_Exception($this->translate('Service not found'));
}
$this->object = $service;
$this->createTabs();