Last Comment Bug 362436 - Allow to search for '---' in versions and milestones
: Allow to search for '---' in versions and milestones
Status: RESOLVED FIXED
:
Product: Bugzilla
Classification: Server Software
Component: Query/Bug List (show other bugs)
: 2.22
: All All
: -- normal (vote)
: Bugzilla 3.0
Assigned To: miketosh
: default-qa
Mentors:
: 398600 (view as bug list)
Depends on:
Blocks: 398557
  Show dependency treegraph
 
Reported: 2006-11-30 20:26 PST by Prasad Wani
Modified: 2008-07-01 00:07 PDT (History)
4 users (show)
mkanat: approval+
mkanat: approval3.0+
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Patch for Bugzilla/Search.pm (660 bytes, patch)
2007-10-04 13:42 PDT, miketosh
justdave: review+
Details | Diff | Splinter Review

Description Prasad Wani 2006-11-30 20:26:15 PST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8

I setup the bugzilla 2.22 and having problem for finding the bug with version name as "---". There are already lots of bugs file under that version. But whenever I am using advance search and select version "---" its giving me Zaro results. But if i know the bug number it is able to find.

Reproducible: Always
Comment 1 Frédéric Buclin 2006-12-01 04:28:16 PST
I can reproduce the bug on tip.

The problem is that Search.pm uses 'anyexact' for fields having legal values...

    foreach my $field ($params->param()) {
        if (lsearch(\@legal_fields, $field) != -1) {
            push(@specialchart, [$field, "anyexact",
                                 join(',', $params->param($field))]);
        }
    }


... but the field value '---' is converted back to '' if the field is not a target milestone, explaining why the query returns no result with version = '---':

         ",anyexact" => sub {
             my @list;
             foreach my $w (split(/,/, $v)) {
                 if ($w eq "---" && $f !~ /milestone/) {
                     $w = "";
                 }
                 $q = $dbh->quote($w);
                 trick_taint($q);
                 push(@list, $q);
             }
             if (@list) {
                 $term = "$ff IN (" . join (',', @list) . ")";
             }
         },

Is there any good reason to convert '---' into ''?
Comment 2 Max Kanat-Alexander 2006-12-01 13:08:57 PST
(In reply to comment #1)
> Is there any good reason to convert '---' into ''?

  For resolution.
Comment 3 Prasad Wani 2007-01-30 21:38:24 PST
How to resolve this problem because every time if I do any search with version == ---. You always get zarro bugs found!

Comment 4 Max Kanat-Alexander 2007-01-31 17:58:30 PST
This is not a blocker. You cannot currently search for --- in a field, and that's a known problem. Try renaming your version to "--" instead for now.
Comment 5 Frédéric Buclin 2007-10-04 13:21:50 PDT
*** Bug 398600 has been marked as a duplicate of this bug. ***
Comment 6 miketosh 2007-10-04 13:24:21 PDT
Instead of converting ALL non-targets to '', why not convert resolution only?  That would make more sense to me.

         ",anyexact" => sub {
             my @list;
             foreach my $w (split(/,/, $v)) {
                 if ($w eq "---" && $f ~ /resolution/) {
                     $w = "";
                 }
                 $q = $dbh->quote($w);
                 trick_taint($q);
                 push(@list, $q);
             }
             if (@list) {
                 $term = "$ff IN (" . join (',', @list) . ")";
             }
         },
Comment 7 miketosh 2007-10-04 13:42:24 PDT
Created attachment 283601 [details] [diff] [review]
Patch for Bugzilla/Search.pm

Assuming resolution is the ONLY time you need to convert '---' to '', here is a patch built for 3.1.2
Comment 8 Max Kanat-Alexander 2007-10-05 15:04:11 PDT
Comment on attachment 283601 [details] [diff] [review]
Patch for Bugzilla/Search.pm

I'm not qualified to review Search.pm--ask somebody else. (See the Reviewer List.)
Comment 9 Frédéric Buclin 2007-10-21 03:44:59 PDT
Comment on attachment 283601 [details] [diff] [review]
Patch for Bugzilla/Search.pm

joel, could you review this one-liner?
Comment 10 Dave Miller [:justdave] (justdave@bugzilla.org) 2007-12-05 20:53:10 PST
Comment on attachment 283601 [details] [diff] [review]
Patch for Bugzilla/Search.pm

We should probably be more careful on field names... what if someone creates a custom field that happens to contain the word "resolution" ;)

But yes, having poked through the available values and how they're treated on the other fields, this is definitely the right fix.
Comment 11 miketosh 2007-12-06 05:17:09 PST
Can someone handle checking in this code?  I am not able.
Comment 12 Frédéric Buclin 2007-12-07 04:31:16 PST
tip:

Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.149; previous revision: 1.148
done

3.0.2:

Checking in Bugzilla/Search.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Search.pm,v  <--  Search.pm
new revision: 1.145.2.2; previous revision: 1.145.2.1
done
Comment 13 Max Kanat-Alexander 2008-06-30 23:04:05 PDT
I've decided this isn't important enough to relnote.
Comment 14 Max Kanat-Alexander 2008-07-01 00:07:40 PDT
Added to the release notes for Bugzilla 3.2 in a patch on bug 432331.

Note You need to log in before you can comment on or make changes to this bug.