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
{
if (isset($plain->uuid)) {
return $implementation::loadWithUniqueId(Uuid::fromString($plain->uuid), $this->db);
if (isset($plain->uuid)
&& $instance = $implementation::loadWithUniqueId(Uuid::fromString($plain->uuid), $this->db)
) {
return $instance;
}
if ($implementation === IcingaService::class) {

View File

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