Skip to content

Commit 17aa943

Browse files
committed
fix(form): prevent SQL error
when current user is not member of any group, MySQL may warn about truncated decimal (nonsens, but happens) because groups are tested against IN('') statement
1 parent e4c6ffe commit 17aa943

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

inc/form.class.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -967,12 +967,6 @@ protected function showMyLastForms() : void {
967967
'searchtype' => 'equals',
968968
'value' => 'myself',
969969
],
970-
1 => [
971-
'link' => 'OR',
972-
'field' => 7,
973-
'searchtype' => 'equals',
974-
'value' => 'mygroups',
975-
],
976970
],
977971
'sort' => [
978972
0 => 6
@@ -981,6 +975,15 @@ protected function showMyLastForms() : void {
981975
0 => 'DESC'
982976
],
983977
];
978+
if (count($_SESSION['glpigroups'] ?? []) > 0) {
979+
// The user is member of some groups, then add criteria for those groups
980+
$criteria['criteria'][] = [
981+
'link' => 'OR',
982+
'field' => 7,
983+
'searchtype' => 'equals',
984+
'value' => 'mygroups',
985+
];
986+
}
984987
$backupListLimit = $_SESSION['glpilist_limit'];
985988
$_SESSION['glpilist_limit'] = 5;
986989
$search = Search::getDatas(PluginFormcreatorFormAnswer::class, $criteria, $showColumns);

0 commit comments

Comments
 (0)