mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
Malformed query in popups when MultiEnum fields are present #5219
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#5219
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @piciuriello on GitHub (Jul 3, 2024).
Issue
When you have one or more MultEnum field in a Popup, you select more values in one MultiEnum filter field and you have some other filter value within other fields, the where clause is built without brackets and you get OR and AND clauses mixed with unwanted results.
This problem is not present in ListViews where brackets are put (look at method processSearchForm in include/MVC/View/views/view.list.php)
Possible Fix
Easy fix is in include/Popups/PopupSmarty.php in method _get_where_clause().
Change:
to
Steps to Reproduce the Issue
Context
No response
Version
Bug still present in actual GitHub code (7.14.4)
What browser are you currently using?
Chrome
Browser Version
not significant
Environment Information
not significant
Operating System and Version
not significant
@johnM2401 commented on GitHub (Jul 10, 2024):
Hey @piciuriello !
Thank you for getting in touch and raising this.
I've been trying to replicate this locally on a 7.14.3 environment, but I'm not sure I've been able to do so
Perhaps I've just misunderstood your issue?
I've got multiple conditions set on the "Accounts"->"Member of" popup, with one of them being a MultiEnum field with 2 options selected:

and my results appear to be accurate:

Would you perhaps have a screenshot/example of "unwanted results" given by the popup?
Is it that the MultiEnum field is returning records that contain "Average", in this example?
Or perhaps something else?
Thanks again!
@piciuriello commented on GitHub (Jul 11, 2024):
The unwanted results depends on the data set you have in your module.
The query created by method _get_where_clause() mix OR and AND clauses without brackets, but in SQL AND operator has precedence over OR operator, so in some situations you will have unwanted results.
In you example the where clauses will be build something like this:
name like '%API%' AND testmulti like '%^count^%' OR testmulti like "%^sum^%" AND ...This is semantically different from this (that should be the right syntax):
name like '%API%' AND (testmulti like '%^count^%' OR testmulti like "%^sum^%") AND ...Because in first where clauses your results will have "API" in name AND "count" in testmulti, OR simply "sum" in testmulti (with or without "API" in name).
In the correct where clauses your results will have "API" in name AND one of "count" OR "sum" in testmulti.
I hope I have clarified the point.