From 1cbb0339118e7347382e3b9b6d6ac0317451c870 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 23 Dec 2021 10:25:59 +0100 Subject: [PATCH] ServiceController: load Set and Host before... ...the service, which get's loaded in the parent class fixes #2452 fixes #2449 --- application/controllers/ServiceController.php | 3 ++- library/Director/Db/Branch/UuidLookup.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 72363e7f..7c1adfed 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -39,9 +39,10 @@ class ServiceController extends ObjectController public function init() { - parent::init(); + // Hint: having Host and Set loaded first is important for UUID lookups with legacy URLs $this->loadOptionalHost(); $this->loadOptionalSet(); + parent::init(); $this->addOptionalHostTabs(); $this->addOptionalSetTabs(); } diff --git a/library/Director/Db/Branch/UuidLookup.php b/library/Director/Db/Branch/UuidLookup.php index 67678b52..097a1c3f 100644 --- a/library/Director/Db/Branch/UuidLookup.php +++ b/library/Director/Db/Branch/UuidLookup.php @@ -33,10 +33,10 @@ class UuidLookup $query = $db->select()->from('icinga_service', 'uuid')->where('object_type = ?', $objectType); $query = self::addKeyToQuery($connection, $query, $key); if ($host) { - $query->add('host_id = ?', $host->get('id')); + $query->where('host_id = ?', $host->get('id')); } if ($set) { - $query->add('service_set_id = ?', $set->get('id')); + $query->where('service_set_id = ?', $set->get('id')); } $uuid = self::fetchOptionalUuid($connection, $query);