From efc36fdbb85f8bd5a80ae03e693926b9624f50cc Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 20 Oct 2017 10:23:23 +0200 Subject: [PATCH] ObjectController: Don't let DeploymentLink break the interface on errors This can happen whenever the deployment related config of Zones, Endpoints or ApiUsers is incomplete or missing. This should not break forms needed to fix the problem. --- .../Web/Controller/ObjectController.php | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php index 4fc9efaf..53f3be43 100644 --- a/library/Director/Web/Controller/ObjectController.php +++ b/library/Director/Web/Controller/ObjectController.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Director\Web\Controller; +use Icinga\Exception\IcingaException; use Icinga\Exception\InvalidPropertyException; use Icinga\Exception\NotFoundError; use Icinga\Module\Director\Deployment\DeploymentInfo; @@ -379,18 +380,22 @@ abstract class ObjectController extends ActionController protected function addDeploymentLink() { - $info = new DeploymentInfo($this->db()); - $info->setObject($this->object); + try { + $info = new DeploymentInfo($this->db()); + $info->setObject($this->object); - if (! $this->getRequest()->isApiRequest()) { - $this->actions()->add( - DeploymentLinkForm::create( - $this->db(), - $info, - $this->Auth(), - $this->api() - )->handleRequest() - ); + if (! $this->getRequest()->isApiRequest()) { + $this->actions()->add( + DeploymentLinkForm::create( + $this->db(), + $info, + $this->Auth(), + $this->api() + )->handleRequest() + ); + } + } catch (IcingaException $e) { + // pass (deployment may not be set up yet) } }