ObjectImporter: Retransform sync job settings apply_changes from boolean 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
This commit is contained in:
Eric Lippmann 2024-11-07 11:02:03 +01:00 committed by GitHub
commit aaf51452be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Data;
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;
@ -106,9 +107,13 @@ class ObjectImporter
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);
}
}
}