ObjectImporter, BasketDiff: fallback for baskets...

...with UUID, and no matching entry. Will adjust UUIDs for matching objects
This commit is contained in:
Thomas Gelf 2023-03-07 17:52:59 +01:00
parent 5a732170af
commit 045f4ec941
2 changed files with 6 additions and 4 deletions

View File

@ -120,8 +120,10 @@ class ObjectImporter
*/ */
protected function loadExistingObject(string $implementation, stdClass $plain): ?DbObject protected function loadExistingObject(string $implementation, stdClass $plain): ?DbObject
{ {
if (isset($plain->uuid)) { if (isset($plain->uuid)
return $implementation::loadWithUniqueId(Uuid::fromString($plain->uuid), $this->db); && $instance = $implementation::loadWithUniqueId(Uuid::fromString($plain->uuid), $this->db)
) {
return $instance;
} }
if ($implementation === IcingaService::class) { if ($implementation === IcingaService::class) {

View File

@ -97,8 +97,8 @@ class BasketDiff
public function getCurrentInstance(string $type, string $key, ?UuidInterface $uuid = null) public function getCurrentInstance(string $type, string $key, ?UuidInterface $uuid = null)
{ {
if ($uuid) { if ($uuid && $instance = BasketSnapshot::instanceByUuid($type, $uuid, $this->db)) {
return BasketSnapshot::instanceByUuid($type, $uuid, $this->db); return $instance;
} else { } else {
return BasketSnapshot::instanceByIdentifier($type, $key, $this->db); return BasketSnapshot::instanceByIdentifier($type, $key, $this->db);
} }