Skip to content

Commit

Permalink
DirectorJob: fix restoring from snapshot
Browse files Browse the repository at this point in the history
fixes #2528
  • Loading branch information
raviks789 authored and Thomas-Gelf committed Sep 30, 2022
1 parent 6fe74ea commit 4bca121
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ v1.10.1 (unreleased)

### Configuration Baskets
* FIX: restore Import/Sync/Job when exported with v1.10 (#2620)
* FIX: restoring Job with ImportSource or SyncRule (#2528)

### Database Schema
* FIX: new DB schema failed due to duplicate line in SQL statement (#2609)
Expand Down
15 changes: 15 additions & 0 deletions library/Director/Objects/DirectorJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ public static function import($plain, Db $db, $replace = false)
$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);
if ($id !== null) {
$object->reallySet($idCol, $id);
Expand Down

0 comments on commit 4bca121

Please sign in to comment.