DirectorJob: fix restoring from snapshot

fixes #2528
This commit is contained in:
Ravi Kumar Kempapura Srinivasa 2022-09-30 11:38:00 +02:00 committed by Thomas Gelf
parent 5d199b41d5
commit 2d5d0db77c
2 changed files with 16 additions and 0 deletions

View File

@ -16,6 +16,7 @@ v1.10.1 (unreleased)
### Configuration Baskets ### Configuration Baskets
* FIX: restore Import/Sync/Job when exported with v1.10 (#2620) * FIX: restore Import/Sync/Job when exported with v1.10 (#2620)
* FIX: restoring Job with ImportSource or SyncRule (#2528)
### Database Schema ### Database Schema
* FIX: new DB schema failed due to duplicate line in SQL statement (#2609) * FIX: new DB schema failed due to duplicate line in SQL statement (#2609)

View File

@ -251,6 +251,21 @@ class DirectorJob extends DbObjectWithSettings implements ExportInterface, Insta
$object = static::create([], $db); $object = static::create([], $db);
} }
$settings = (array) $properties['settings'];
if (array_key_exists('source', $settings) && ! (array_key_exists('source_id', $settings))) {
$val = ImportSource::load($settings['source'], $db)->get('id');
$settings['source_id'] = $val;
unset($settings['source']);
}
if (array_key_exists('rule', $settings) && ! (array_key_exists('rule_id', $settings))) {
$val = SyncRule::load($settings['rule'], $db)->get('id');
$settings['rule_id'] = $val;
unset($settings['rule']);
}
$properties['settings'] = (object) $settings;
$object->setProperties($properties); $object->setProperties($properties);
if ($id !== null) { if ($id !== null) {
$object->reallySet($idCol, $id); $object->reallySet($idCol, $id);