-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
FIX ticket list : type_code multiselect search can be an empty value.… #31709
Conversation
… It should not be.
The empty value into the select list means "We don't want any filter". And we should be able to not set any filter on this field so the empty choice should remain into the combo, but no filter should be done in this case. |
84c4394
to
f84e325
Compare
f84e325
to
cf91674
Compare
You are right. Problem is, if we chose this empty value we get a nice error page (here an abstract). Tested on a fresh V17 install without any module. with this nice request
containing this nice WITH clause :
The solution is to remove empty values from the search array. User may still be confused by being able to chose empty value, but at least the search will work. |
Solution is to fix the part of code that generates the SQL by adding a test so if no filter is provided, the SQL must not include the "AND (type_code IN ..." at all. |
htdocs/ticket/list.php
Outdated
@@ -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( |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Anyway, this WHERE clause is generated in natural_search() function, when you pass it an array containing only empty string values ['', '']
. I fixed it.
Fix multiselect on ticket list would allow empty value for type_code
On ticket list, the search for type_code is a multiselect. It can receive an empty value that would mean 'type_code is not set'.
Since type_code is a mandatory value, a search on value 'is not set' should not be allowed.