mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Revert "Add proper respond http codes to service and host controller"
This reverts commit 6df031dc786256e0bd42f8047d6c308e90abedf6. 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:
parent
902c00e836
commit
ce9110d22d
@ -34,11 +34,7 @@ class ErrorController extends ActionController
|
|||||||
$path = preg_split('~/~', $path);
|
$path = preg_split('~/~', $path);
|
||||||
$path = array_shift($path);
|
$path = array_shift($path);
|
||||||
$this->getResponse()->setHttpResponseCode(404);
|
$this->getResponse()->setHttpResponseCode(404);
|
||||||
$title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage());
|
$this->view->message = $this->translate('Page not found.');
|
||||||
$this->view->title = 'Server error: ' . $title;
|
|
||||||
if ($this->getInvokeArg('displayExceptions')) {
|
|
||||||
$this->view->stackTrace = $exception->getTraceAsString();
|
|
||||||
}
|
|
||||||
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
|
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
|
||||||
$this->view->message .= ' ' . sprintf(
|
$this->view->message .= ' ' . sprintf(
|
||||||
$this->translate('Enabling the "%s" module might help!'),
|
$this->translate('Enabling the "%s" module might help!'),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* 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\AcknowledgeProblemCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
@ -27,22 +26,12 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||||||
*/
|
*/
|
||||||
public function init()
|
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'));
|
$host = new Host($this->backend, $this->params->get('host'));
|
||||||
|
|
||||||
$this->applyRestriction('monitoring/hosts/filter', $host);
|
$this->applyRestriction('monitoring/hosts/filter', $host);
|
||||||
|
|
||||||
if ($host->fetch() === false) {
|
if ($host->fetch() === false) {
|
||||||
throw new Zend_Controller_Action_Exception(
|
throw new Zend_Controller_Action_Exception($this->translate('Host not found'));
|
||||||
sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')),
|
|
||||||
404
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$this->object = $host;
|
$this->object = $host;
|
||||||
$this->createTabs();
|
$this->createTabs();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* 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\AcknowledgeProblemCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||||
@ -27,22 +26,12 @@ class Monitoring_ServiceController extends MonitoredObjectController
|
|||||||
*/
|
*/
|
||||||
public function init()
|
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'));
|
$service = new Service($this->backend, $this->params->get('host'), $this->params->get('service'));
|
||||||
|
|
||||||
$this->applyRestriction('monitoring/services/filter', $service);
|
$this->applyRestriction('monitoring/services/filter', $service);
|
||||||
|
|
||||||
if ($service->fetch() === false) {
|
if ($service->fetch() === false) {
|
||||||
throw new Zend_Controller_Action_Exception(
|
throw new Zend_Controller_Action_Exception($this->translate('Service not found'));
|
||||||
sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')),
|
|
||||||
404
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$this->object = $service;
|
$this->object = $service;
|
||||||
$this->createTabs();
|
$this->createTabs();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user