Skip to content

Commit

Permalink
fix(form): duplication exception (#1818)
Browse files Browse the repository at this point in the history
fix(form): duplication exception
  • Loading branch information
btry committed Jun 16, 2020
1 parent aaaf7a7 commit c66e518
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,18 @@ public function duplicate() {
$linker = new PluginFormcreatorLinker();

$export = $this->export(true);
$new_form_id = static::import($linker, $export);
try {
$new_form_id = static::import($linker, $export);
} catch (ImportFailureException $e) {
$forms = $linker->getObjectsByType(PluginFormcreatorForm::class);
$form = reset($forms);
$form->update([
'id' => $form->getID(),
'name' => $form->fields['name'] . ' [' . __('Errored duplicate', 'formcreator') . ']',
]);
Session::addMessageAfterRedirect($e->getMessage(), false, WARNING);
return false;
}

if ($new_form_id === false) {
return false;
Expand Down

0 comments on commit c66e518

Please sign in to comment.