UuidLookup: host_id VS host in branch

This commit is contained in:
Thomas Gelf 2022-09-20 11:54:10 +02:00
parent 8b1513830c
commit ae0992f196

View File

@ -99,6 +99,10 @@ class UuidLookup
$query = self::addKeyToQuery($connection, $db->select()->from($table, 'uuid'), $key);
$uuid = self::fetchOptionalUuid($connection, $query);
if ($uuid === null && $branch->isBranch()) {
if (is_array($key) && isset($key['host_id'])) {
$key['host'] = IcingaHost::load($key['host_id'], $connection)->getObjectName();
unset($key['host_id']);
}
$query = self::addKeyToQuery($connection, $db->select()->from("branched_$table", 'uuid'), $key);
$query->where('branch_uuid = ?', $connection->quoteBinary($branch->getUuid()->getBytes()));
$uuid = self::fetchOptionalUuid($connection, $query);