Closed Bug 879055 Opened 8 years ago Closed 8 years ago

anywordssubstr search returns incorrect results

Categories

(Bugzilla :: Query/Bug List, defect, P1)

defect

Tracking

()

RESOLVED FIXED
Bugzilla 4.4

People

(Reporter: mail, Assigned: mail)

References

Details

Attachments

(1 file)

The following query:
https://landfill.bugzilla.org/bugzilla-4.4-branch/buglist.cgi?bug_id=19829&bug_id_type=anyexact&f1=flagtypes.name&list_id=50301&o1=anywordssubstr&query_format=advanced&v1=blocker%2B%2Cfoo%2B&debug=1

returns bug 19829, despite it having the flags blocker? and foo?

This is due to an error in the SQL that Bugzilla::Search generates.

(EXISTS ( SELECT 1 FROM bugs bugs_2 LEFT JOIN attachments AS attachments_2 ON bugs_2.bug_id = attachments_2.bug_id LEFT JOIN flags AS flags_2 ON bugs_2.bug_id = flags_2.bug_id AND (flags_2.attach_id = attachments_2.attach_id OR flags_2.attach_id IS NULL) LEFT JOIN flagtypes AS flagtypes_2 ON flags_2.type_id = flagtypes_2.id WHERE bugs_2.bug_id = bugs.bug_id AND INSTR(CONCAT(flagtypes_2.name, flags_2.status), 'blocker+') > 0 OR INSTR(CONCAT(flagtypes_2.name, flags_2.status), 'foo+') > 0 ))

AND has precedence over OR ( http://dev.mysql.com/doc/refman/5.1/en/operator-precedence.html ), so as long as ANY bug has foo+ as a flag, the whole block above will always return true.

The solution is to wrap some parenthesis around the last two statements.
Flags: blocking4.4.1?
Severity: critical → normal
Flags: blocking4.4.1? → blocking4.4.1+
Attached patch v1 patchSplinter Review
Attachment #757733 - Flags: review?(glob)
Comment on attachment 757733 [details] [diff] [review]
v1 patch

r=glob
Attachment #757733 - Flags: review?(glob) → review+
Flags: approval?
Flags: approval4.4?
I will let glob commit this patch.
Flags: approval?
Flags: approval4.4?
Flags: approval4.4+
Flags: approval+
Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Search.pm
Committed revision 8629.

Committing to: bzr+ssh://bjones%40mozilla.com@bzr.mozilla.org/bugzilla/4.4/
modified Bugzilla/Search.pm
Committed revision 8564.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Blocks: 880315
You need to log in before you can comment on or make changes to this bug.