From fb557c73932a67586f58b649e24d821af4c33adc Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 18 Dec 2024 12:53:57 +0100 Subject: [PATCH] Don't show `parents` `children` tab if `icingadb.schema` version `< 6` --- application/controllers/HostController.php | 19 ++++++++++------- application/controllers/ServiceController.php | 21 ++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 2a2a1c949..f6c2d3e74 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -8,6 +8,7 @@ use Icinga\Exception\NotFoundError; use Icinga\Module\Icingadb\Command\Object\GetObjectCommand; use Icinga\Module\Icingadb\Command\Transport\CommandTransport; +use Icinga\Module\Icingadb\Common\Backend; use Icinga\Module\Icingadb\Common\CommandActions; use Icinga\Module\Icingadb\Common\HostLinks; use Icinga\Module\Icingadb\Common\Links; @@ -432,13 +433,17 @@ protected function fetchNodes(bool $fetchParents = false): Query protected function createTabs(): Tabs { - $hasDependencyNode = DependencyNode::on($this->getDb()) - ->columns('1') - ->filter(Filter::all( - Filter::equal('host_id', $this->host->id), - Filter::unlike('service_id', '*') - )) - ->first() !== null; + if (Backend::getDbSchemaVersion() < 6) { + $hasDependencyNode = false; + } else { + $hasDependencyNode = DependencyNode::on($this->getDb()) + ->columns('1') + ->filter(Filter::all( + Filter::equal('host_id', $this->host->id), + Filter::unlike('service_id', '*') + )) + ->first() !== null; + } $tabs = $this->getTabs() ->add('index', [ diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index c959fe614..de80d98f4 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -8,6 +8,7 @@ use Icinga\Exception\NotFoundError; use Icinga\Module\Icingadb\Command\Object\GetObjectCommand; use Icinga\Module\Icingadb\Command\Transport\CommandTransport; +use Icinga\Module\Icingadb\Common\Backend; use Icinga\Module\Icingadb\Common\CommandActions; use Icinga\Module\Icingadb\Common\Links; use Icinga\Module\Icingadb\Common\ServiceLinks; @@ -400,13 +401,17 @@ protected function fetchNodes(bool $fetchParents = false): Query protected function createTabs(): Tabs { - $hasDependecyNode = DependencyNode::on($this->getDb()) - ->columns('1') - ->filter(Filter::all( - Filter::equal('service_id', $this->service->id), - Filter::equal('host_id', $this->service->host_id) - )) - ->first() !== null; + if (Backend::getDbSchemaVersion() < 6) { + $hasDependencyNode = false; + } else { + $hasDependencyNode = DependencyNode::on($this->getDb()) + ->columns('1') + ->filter(Filter::all( + Filter::equal('service_id', $this->service->id), + Filter::equal('host_id', $this->service->host_id) + )) + ->first() !== null; + } $tabs = $this->getTabs() ->add('index', [ @@ -418,7 +423,7 @@ protected function createTabs(): Tabs 'url' => ServiceLinks::history($this->service, $this->service->host) ]); - if ($hasDependecyNode) { + if ($hasDependencyNode) { $tabs->add('parents', [ 'label' => t('Parents'), 'url' => Url::fromPath(