From b47478293f7efa2ec30e05a2c0c19c000bba65e7 Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:51:38 +0200 Subject: [PATCH] fetch `$this->affectedHost->get('id')` only if `$this->affectedHost->get('id')` is not null for service set --- .../Web/Table/IcingaServiceSetServiceTable.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/library/Director/Web/Table/IcingaServiceSetServiceTable.php b/library/Director/Web/Table/IcingaServiceSetServiceTable.php index 8df6f2ed..ee8a3efe 100644 --- a/library/Director/Web/Table/IcingaServiceSetServiceTable.php +++ b/library/Director/Web/Table/IcingaServiceSetServiceTable.php @@ -195,14 +195,16 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable assert($connection instanceof Db); $builder = new ServiceSetQueryBuilder($connection, $this->branchUuid); $query = $builder->selectServicesForSet($this->set); - if ($hostId = $this->affectedHost->get('id') !== null) { - $query->joinLeft( - ['hsb' => 'icinga_host_service_blacklist'], - $this->db()->quoteInto('o.id = hsb.service_id AND hsb.host_id = ?', $hostId), - [] - )->columns([ - 'blacklisted' => "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END" - ]); + if ($this->affectedHost) { + if ($hostId = $this->affectedHost->get('id')) { + $query->joinLeft( + ['hsb' => 'icinga_host_service_blacklist'], + $this->db()->quoteInto('o.id = hsb.service_id AND hsb.host_id = ?', $hostId), + [] + )->columns([ + 'blacklisted' => "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END" + ]); + } } return $query->limit(100);