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

Conversation

thomas-Ngr
Copy link
Contributor

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.

Capture d’écran_2024-11-06_11-49-56

@eldy
Copy link
Member

eldy commented Nov 6, 2024

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.

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Nov 6, 2024
@thomas-Ngr thomas-Ngr force-pushed the 17.0_fix_ticket_list_empty_multiselect branch 2 times, most recently from 84c4394 to f84e325 Compare November 7, 2024 09:54
@thomas-Ngr thomas-Ngr force-pushed the 17.0_fix_ticket_list_empty_multiselect branch from f84e325 to cf91674 Compare November 7, 2024 09:57
@thomas-Ngr
Copy link
Contributor Author

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.

image

with this nice request

SELECT t.rowid,t.entity,t.ref,t.track_id,t.fk_user_create,t.origin_email,t.subject,t.type_code,t.category_code,t.severity_code,t.fk_soc,t.notify_tiers_at_create,t.fk_project,t.datec,t.date_read,t.date_last_msg_sent,t.fk_user_assign,t.date_close,t.tms,t.message,t.email_msgid,t.progress,t.email_date,t.resolution,t.fk_statut,t.import_key FROM llx_ticket as t LEFT JOIN llx_societe as s ON (t.fk_soc = s.rowid) WHERE t.entity IN (1) AND (type_code IN ()) ORDER BY t.datec DESC LIMIT 21

containing this nice WITH clause :

AND (type_code IN ())


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.

@eldy
Copy link
Member

eldy commented Nov 8, 2024

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.

@eldy eldy added PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) and removed Discussion Some questions or discussions are opened and wait answers of author or other people to be processed labels Nov 8, 2024
@@ -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.

@thomas-Ngr thomas-Ngr closed this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants