Skip to content

Commit

Permalink
fix(condition): fix export
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Feb 5, 2020
1 parent b380b79 commit 7db999d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
9 changes: 1 addition & 8 deletions inc/condition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$input['items_id'] = $containerId;

$item = new self();
Expand Down Expand Up @@ -174,14 +175,6 @@ public function export($remove_uuid = false) {
$question = new PluginFormcreatorQuestion();
$question->getFromDB($condition['plugin_formcreator_questions_id']);
$condition['plugin_formcreator_questions_id'] = $question->fields['uuid'];

$containerType = $condition['itemtype'];
if (!class_exists($containerType) || !is_subclass_of($containerType, PluginFormcreatorConditionnableInterface::class)) {
return false;
}
$container = new $containerType();
$container->getFromDB($condition['items_id']);
$condition['items_id'] = $container->fields['uuid'];
}
unset($condition[$idToRemove]);

Expand Down
2 changes: 2 additions & 0 deletions inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
$input[$sectionFk] = $containerId;

$input['_skip_checks'] = true;

$item = new self();
Expand Down
2 changes: 2 additions & 0 deletions inc/section.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$formFk = PluginFormcreatorForm::getForeignKeyField();
$input[$formFk] = $containerId;

$input['_skip_checks'] = true;

$item = new self();
Expand Down
1 change: 0 additions & 1 deletion tests/suite-unit/PluginFormcreatorCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public function testExport() {
// Test the exported data
$fieldsWithoutID = [
'itemtype',
'items_id',
'plugin_formcreator_questions_id',
'show_condition',
'show_value',
Expand Down

0 comments on commit 7db999d

Please sign in to comment.