Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX ticket list : type_code multiselect search can be an empty value.… #31709

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions htdocs/ticket/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@
continue;
} elseif ($key == 'type_code') {
$newarrayoftypecodes = is_array($search[$key]) ? $search[$key] : (!empty($search[$key]) ? explode(',', $search[$key]) : array());
$newarrayoftypecodes = array_filter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is value of $newarrayoftypecodes here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on what was filtered by the user.

  • if no filter, $newarrayoftypecodes == []
  • if filter 'empty value', $newarrayoftypecodes == [0 => '']
  • if filter 'HELP', $newarrayoftypecodes == [0 => 'HELP']
  • if filter 'HELP' + 'empty value', $newarrayoftypecodes == [0 => '', 1 => 'HELP'] (I observed that the empty value comes on index 0)

Copy link
Member

@eldy eldy Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we must found when the entry 0 => '' is added to disabled it.
I do not experience troubles in develop so may be you can have a look to fix the same way.

Copy link
Contributor Author

@thomas-Ngr thomas-Ngr Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not experience troubles in develop

Well, I do. On a fresh install on commit 2eb5bca from Wed Nov 13 11:36:05 . Please see the screencast. NB - the automatic setting of choice 'other' is not in v17, which I am fixing.

ticket-list

Anyway, this WHERE clause is generated in natural_search() function, when you pass it an array containing only empty string values ['', '']. I fixed it.

$newarrayoftypecodes,
function ($var) {
return !(empty($var) && $var !== '0');
}
);
if (count($newarrayoftypecodes)) {
$sql .= natural_search($key, join(',', $newarrayoftypecodes), 3);
}
Expand Down
Loading