Skip to content

Commit

Permalink
ObjectImporter: Retransform sync job settings apply_changes from bo…
Browse files Browse the repository at this point in the history
…olean to 'y' or 'n' (#2904)

Sync jobs restored from a basket snapshot with `apply_changes` settings
set to `Yes`, runs without applying any changes to the objects affected
by the sync rule. This happens as the value of the setting is exported
as a boolean but is not retransformed back to `y` or `n` while
importing.


fixes ref/IP/53326
  • Loading branch information
lippserd authored Nov 7, 2024
2 parents 2d332a2 + 44a8bbb commit aaf5145
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions library/Director/Data/ObjectImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use gipfl\Json\JsonDecodeException;
use gipfl\Json\JsonString;
use Icinga\Module\Director\Data\Db\DbDataFormatter;
use Icinga\Module\Director\Data\Db\DbObject;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\DirectorObject\Automation\Basket;
Expand Down Expand Up @@ -106,9 +107,13 @@ protected function fixRelations(string $implementation, stdClass $plain)
unset($settings->source);
}
$rule = $settings->rule ?? null;
if ($rule && !isset($settings->rule_id)) {
$settings->rule_id = SyncRule::load($rule, $this->db)->get('id');
unset($settings->rule);
if ($rule) {
if (! isset($settings->rule_id)) {
$settings->rule_id = SyncRule::load($rule, $this->db)->get('id');
unset($settings->rule);
}

$settings->apply_changes = DbDataFormatter::normalizeBoolean($settings->apply_changes);
}
}
}
Expand Down

0 comments on commit aaf5145

Please sign in to comment.