From e17c5a37adc6ab5bcd479f7d1e9a7e0a6206c935 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 13 Oct 2020 15:19:14 +0200 Subject: [PATCH] fix(targetticket,targetchange): handle import failure on missing question Signed-off-by: Thierry Bugier --- inc/targetchange.class.php | 4 ++++ inc/targetticket.class.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/inc/targetchange.class.php b/inc/targetchange.class.php index 03082259b..5fee24d0d 100644 --- a/inc/targetchange.class.php +++ b/inc/targetchange.class.php @@ -216,6 +216,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con } /**@var PluginFormcreatorQuestion $question */ $question = $linker->getObject($input[$fieldSetting['field']], PluginFormcreatorQuestion::class); + if ($question === false) { + $typeName = strtolower(self::getTypeName()); + throw new ImportFailureException(sprintf(__('failed to add or update the %1$s %2$s: a question is missing and is used in a parameter of the target', 'formceator'), $typeName, $input['name'])); + } $input[$fieldSetting['field']] = $question->getID(); } diff --git a/inc/targetticket.class.php b/inc/targetticket.class.php index a6e61a5a0..ace1df7fe 100644 --- a/inc/targetticket.class.php +++ b/inc/targetticket.class.php @@ -1107,6 +1107,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con } /**@var PluginFormcreatorQuestion $question */ $question = $linker->getObject($input[$fieldSetting['field']], PluginFormcreatorQuestion::class); + if ($question === false) { + $typeName = strtolower(self::getTypeName()); + throw new ImportFailureException(sprintf(__('failed to add or update the %1$s %2$s: a question is missing and is used in a parameter of the target', 'formceator'), $typeName, $input['name'])); + } $input[$fieldSetting['field']] = $question->getID(); }