From 5419d4428c86c488a43124f85e5407d7cbae6541 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:47 +0200 Subject: Adding upstream version 1.11.1. Signed-off-by: Daniel Baumann --- library/Director/Db/Branch/UuidLookup.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'library/Director/Db/Branch/UuidLookup.php') diff --git a/library/Director/Db/Branch/UuidLookup.php b/library/Director/Db/Branch/UuidLookup.php index b340e07..4db7866 100644 --- a/library/Director/Db/Branch/UuidLookup.php +++ b/library/Director/Db/Branch/UuidLookup.php @@ -15,18 +15,13 @@ use function is_string; class UuidLookup { /** - * @param Db $connection - * @param Branch $branch - * @param string $objectType * @param int|string $key - * @param IcingaHost|null $host - * @param IcingaServiceSet $set * @return ?UuidInterface */ public static function findServiceUuid( Db $connection, Branch $branch, - $objectType = null, + ?string $objectType = null, $key = null, IcingaHost $host = null, IcingaServiceSet $set = null @@ -37,11 +32,20 @@ class UuidLookup $query->where('object_type = ?', $objectType); } $query = self::addKeyToQuery($connection, $query, $key); - if ($host) { - $query->where('host_id = ?', $host->get('id')); - } if ($set) { - $query->where('service_set_id = ?', $set->get('id')); + $setId = $set->get('id'); + if ($setId === null) { + $query->where('1 = 0'); + } else { + $query->where('service_set_id = ?', $setId); + } + } elseif ($host) { + $hostId = $host->get('id'); + if ($hostId === null) { + $query->where('1 = 0'); + } else { + $query->where('host_id = ?', $hostId); + } } $uuid = self::fetchOptionalUuid($connection, $query); @@ -100,7 +104,7 @@ class UuidLookup $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(); + $key['host'] = IcingaHost::loadWithAutoIncId((int) $key['host_id'], $connection)->getObjectName(); unset($key['host_id']); } $query = self::addKeyToQuery($connection, $db->select()->from("branched_$table", 'uuid'), $key); -- cgit v1.2.3