UuidLookup: fix host/set related fallback

This commit is contained in:
Thomas Gelf 2022-09-15 11:45:32 +02:00
parent 8bfbe2a80f
commit 410913e512

View File

@ -47,15 +47,21 @@ class UuidLookup
if ($uuid === null && $branch->isBranch()) { if ($uuid === null && $branch->isBranch()) {
// TODO: use different tables? // 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); $query = self::addKeyToQuery($connection, $query, $key);
if ($host) { if ($host) {
// TODO: uuid? // TODO: uuid?
$query->add('host = ?', $host->getObjectName()); $query->where('host = ?', $host->getObjectName());
} }
if ($set) { if ($set) {
$query->add('service_set = ?', $set->getObjectName()); $query->where('service_set = ?', $set->getObjectName());
} }
$uuid = self::fetchOptionalUuid($connection, $query); $uuid = self::fetchOptionalUuid($connection, $query);
} }