Skip to content

Commit ba6ed88

Browse files
committed
fix(targetticket): prevent exception in inconsistent target ticket
1 parent f90c4df commit ba6ed88

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

inc/question.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ public function deleteObsoleteItems(CommonDBTM $container, array $exclude) : boo
12141214
* Get the field object representing the question
12151215
* @return PluginFormcreatorFieldInterface|null
12161216
*/
1217-
public function getSubField(): PluginFormcreatorFieldInterface {
1217+
public function getSubField(): ?PluginFormcreatorFieldInterface {
12181218
if ($this->isNewItem()) {
12191219
return null;
12201220
}

inc/targetticket.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,10 @@ protected function setTargetAssociatedItem(array $data, PluginFormcreatorFormAns
12261226
// find the itemtype of the associated item
12271227
$associateQuestion = $this->fields['associate_question'];
12281228
$question = new PluginFormcreatorQuestion();
1229-
$question->getFromDB($associateQuestion);
1229+
if (!$question->getFromDB($associateQuestion)) {
1230+
Toolbox::logError(sprintf("Question ID %s not found and should be used in target ticket ID %s", $associateQuestion, $this-getID()));
1231+
break;
1232+
}
12301233
/** @var GlpiPlugin\Formcreator\Field\DropdownField */
12311234
$field = $question->getSubField();
12321235
$itemtype = $field->getSubItemtype();

0 commit comments

Comments
 (0)