Skip to content

Commit

Permalink
fix(form): prevent SQL error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
btry committed Nov 18, 2022
1 parent e4c6ffe commit 17aa943
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,12 +967,6 @@ protected function showMyLastForms() : void {
'searchtype' => 'equals',
'value' => 'myself',
],
1 => [
'link' => 'OR',
'field' => 7,
'searchtype' => 'equals',
'value' => 'mygroups',
],
],
'sort' => [
0 => 6
Expand All @@ -981,6 +975,15 @@ protected function showMyLastForms() : void {
0 => 'DESC'
],
];
if (count($_SESSION['glpigroups'] ?? []) > 0) {
// The user is member of some groups, then add criteria for those groups
$criteria['criteria'][] = [
'link' => 'OR',
'field' => 7,
'searchtype' => 'equals',
'value' => 'mygroups',
];
}
$backupListLimit = $_SESSION['glpilist_limit'];
$_SESSION['glpilist_limit'] = 5;
$search = Search::getDatas(PluginFormcreatorFormAnswer::class, $criteria, $showColumns);
Expand Down

0 comments on commit 17aa943

Please sign in to comment.