From 410913e51233194c0cd2b7fe7070cdd416b71273 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 15 Sep 2022 11:45:32 +0200 Subject: [PATCH] UuidLookup: fix host/set related fallback --- library/Director/Db/Branch/UuidLookup.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/library/Director/Db/Branch/UuidLookup.php b/library/Director/Db/Branch/UuidLookup.php index 31284a8b..f9f17478 100644 --- a/library/Director/Db/Branch/UuidLookup.php +++ b/library/Director/Db/Branch/UuidLookup.php @@ -47,15 +47,21 @@ class UuidLookup if ($uuid === null && $branch->isBranch()) { // TODO: use different tables? - $query = $db->select()->from('branched_icinga_service', 'uuid')->where('object_type = ?', $objectType); + $query = $db->select() + ->from('branched_icinga_service', 'uuid') + ->where('branch_uuid = ?', $connection->quoteBinary($branch->getUuid()->getBytes())); + if ($objectType) { + $query->where('object_type = ?', $objectType); + } $query = self::addKeyToQuery($connection, $query, $key); if ($host) { // TODO: uuid? - $query->add('host = ?', $host->getObjectName()); + $query->where('host = ?', $host->getObjectName()); } if ($set) { - $query->add('service_set = ?', $set->getObjectName()); + $query->where('service_set = ?', $set->getObjectName()); } + $uuid = self::fetchOptionalUuid($connection, $query); }