Skip to content

Commit

Permalink
Fix sync rule restore from snapshot on name change
Browse files Browse the repository at this point in the history
Icinga director throws error when we try to restore sync rule from snapshot of the configuration basket after its name has been changed.
  • Loading branch information
raviks789 committed Jan 28, 2022
1 parent b04fe28 commit 34daa0b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions library/Director/Data/Db/DbObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,11 @@ protected function reallySet($key, $value)
return $this;
}

$this->hasBeenModified = true;
$this->modifiedProperties[$key] = true;
if ($key !== $this->autoincKeyName) {
$this->hasBeenModified = true;
$this->modifiedProperties[$key] = true;
}

$this->properties[$key] = $value;
return $this;
}
Expand Down Expand Up @@ -1014,6 +1017,17 @@ public function createWhere()
$originalId
);
}

$key = $this->getKeyName();
$val = $this->get($key);
if ($val) {
$this->properties[$this->autoincKeyName] = null;
return $this->db->quoteInto(
sprintf("%s = ? AND %s = '$val'", $this->autoincKeyName, $key),
$id
);
}

return $this->db->quoteInto(
sprintf('%s = ?', $this->autoincKeyName),
$id
Expand Down

0 comments on commit 34daa0b

Please sign in to comment.