Skip to content

Commit ae28ed6

Browse files
committed
fix: log more errors, and update obsolete error logging
1 parent 093b0d1 commit ae28ed6

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

inc/fields.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static function isVisible(PluginFormcreatorConditionnableInterface $item,
202202

203203
default:
204204
// This should not happen : inconsistency in the database
205-
Toolbox::logError("Inconsistency detected in conditions: show rule set but no condition found, $itemtype ID=$itemId");
205+
trigger_error("Inconsistency detected in conditions: show rule set but no condition found, $itemtype ID=$itemId", E_USER_WARNING);
206206
self::$visibility[$itemtype][$itemId] = $getParentVisibility();
207207
return self::$visibility[$itemtype][$itemId];
208208
break;

inc/issue.class.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,21 +817,25 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
817817
case "glpi_plugin_formcreator_issues.name":
818818
$name = $data[$num][0]['name'];
819819
$subItemtype = $data['raw']['itemtype'];
820+
$content = '';
820821
switch ($subItemtype) {
821822
case Ticket::class:
822823
$ticket = new Ticket();
823-
$ticket->getFromDB($id);
824+
if (!$ticket->getFromDB($id)) {
825+
trigger_error(sprintf("Ticket ID %s not found", $id), E_USER_WARNING);
826+
break;
827+
}
824828
$content = $ticket->fields['content'];
825829
break;
826830

827831
case PluginFormcreatorFormAnswer::class:
828832
$formAnswer = PluginFormcreatorCommon::getFormAnswer();
829-
$formAnswer->getFromDB($id);
833+
if (!$formAnswer->getFromDB($id)) {
834+
trigger_error(sprintf("Formanswer ID %s not found", $id), E_USER_WARNING);
835+
break;
836+
}
830837
$content = $formAnswer->parseTags($formAnswer->getFullForm());
831838
break;
832-
833-
default:
834-
$content = '';
835839
}
836840
$link = self::getFormURLWithID($data['id']);
837841

inc/ldapdropdown.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static function getDropdownValue($post, $json = true) {
139139
$limitexceeded = in_array(ldap_errno($ds), [4, 11]);
140140

141141
if ($limitexceeded) {
142-
Toolbox::logError("LDAP size limit exceeded");
142+
trigger_error("LDAP size limit exceeded", E_USER_ERROR);
143143
}
144144

145145
unset($entries['count']);

inc/targetticket.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,11 +1071,11 @@ protected function setTargetType(array $data, PluginFormcreatorFormAnswer $forma
10711071
if (isset($type['answer']) && ctype_digit($type['answer'])) {
10721072
$type = $type['answer'];
10731073
} else {
1074-
// Invalid value. Maybe the questin is not compatible.
1074+
// Invalid value. Maybe the question is not compatible.
10751075
trigger_error(sprintf("Attempt to set the type of a ticket from an incompatible question. Check the target ticket %s of the form ID=%s",
10761076
$this->fields['name'],
10771077
$this->getForm()->getID()
1078-
));
1078+
), E_USER_ERROR);
10791079
$type = null;
10801080
}
10811081
break;
@@ -1208,7 +1208,7 @@ protected function setTargetAssociatedItem(array $data, PluginFormcreatorFormAns
12081208
$associateQuestion = $this->fields['associate_question'];
12091209
$question = new PluginFormcreatorQuestion();
12101210
if (!$question->getFromDB($associateQuestion)) {
1211-
Toolbox::logError(sprintf("Question ID %s not found and should be used in target ticket ID %s", $associateQuestion, $this-getID()));
1211+
trigger_error(sprintf("Question ID %s not found and should be used in target ticket ID %s", $associateQuestion, $this->getID()), E_USER_ERROR);
12121212
break;
12131213
}
12141214
/** @var GlpiPlugin\Formcreator\Field\DropdownField */

0 commit comments

Comments
 (0)