diff options
Diffstat (limited to 'Bugzilla/Search/Quicksearch.pm')
-rw-r--r-- | Bugzilla/Search/Quicksearch.pm | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index fd9d796d1..c3c11b728 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -161,6 +161,8 @@ sub quicksearch { ThrowUserError('quicksearch_invalid_query') if ($words[0] =~ /^(?:AND|OR)$/ || $words[$#words] =~ /^(?:AND|OR|NOT)$/); + $fulltext = Bugzilla->user->setting('quicksearch_fulltext') eq 'on' ? 1 : 0; + my (@qswords, @or_group); while (scalar @words) { my $word = shift @words; @@ -187,6 +189,10 @@ sub quicksearch { } unshift(@words, "-$word"); } + # --comment and ++comment disable or enable fulltext searching + elsif ($word =~ /^(--|\+\+)comments?$/i) { + $fulltext = $1 eq '--' ? 0 : 1; + } else { # OR groups words together, as OR has higher precedence than AND. push(@or_group, $word); @@ -203,12 +209,12 @@ sub quicksearch { shift(@qswords) if $bug_status_set; my (@unknownFields, %ambiguous_fields); - $fulltext = Bugzilla->user->setting('quicksearch_fulltext') eq 'on' ? 1 : 0; # Loop over all main-level QuickSearch words. foreach my $qsword (@qswords) { my @or_operand = parse_line('\|', 1, $qsword); foreach my $term (@or_operand) { + next unless defined $term; my $negate = substr($term, 0, 1) eq '-'; if ($negate) { $term = substr($term, 1); @@ -339,6 +345,7 @@ sub _handle_status_and_resolution { sub _handle_special_first_chars { my ($qsword, $negate) = @_; + return if $qsword eq ''; my $firstChar = substr($qsword, 0, 1); my $baseWord = substr($qsword, 1); @@ -377,15 +384,18 @@ sub _handle_field_names { # Flag and requestee shortcut if ($or_operand =~ /^(?:flag:)?([^\?]+\?)([^\?]*)$/) { - my ($flagtype, $requestee) = ($1, $2); - addChart('flagtypes.name', 'substring', $flagtype, $negate); - if ($requestee) { - # AND - $chart++; - $and = $or = 0; - addChart('requestees.login_name', 'substring', $requestee, $negate); + # BMO: Do not treat custom fields as flags if value is ? + if ($1 !~ /^cf_/) { + my ($flagtype, $requestee) = ($1, $2); + addChart('flagtypes.name', 'substring', $flagtype, $negate); + if ($requestee) { + # AND + $chart++; + $and = $or = 0; + addChart('requestees.login_name', 'substring', $requestee, $negate); + } + return 1; } - return 1; } # Generic field1,field2,field3:value1,value2 notation. @@ -410,6 +420,7 @@ sub _handle_field_names { $bug_status_set = 1; } foreach my $value (@values) { + next unless defined $value; my $operator = FIELD_OPERATOR->{$translated} || 'substring'; # If the string was quoted to protect some special # characters such as commas and colons, we need @@ -482,6 +493,7 @@ sub _translate_field_name { sub _special_field_syntax { my ($word, $negate) = @_; + return unless defined($word); # P1-5 Syntax if ($word =~ m/^P(\d+)(?:-(\d+))?$/i) { @@ -517,6 +529,7 @@ sub _special_field_syntax { sub _default_quicksearch_word { my ($word, $negate) = @_; + return unless defined($word); if (!grep { lc($word) eq $_ } PRODUCT_EXCEPTIONS and length($word) > 2) { addChart('product', 'substring', $word, $negate); @@ -535,10 +548,15 @@ sub _default_quicksearch_word { addChart('short_desc', 'substring', $word, $negate); addChart('status_whiteboard', 'substring', $word, $negate); addChart('content', 'matches', _matches_phrase($word), $negate) if $fulltext; + + # BMO Bug 664124 - Include the crash signature (sig:) field in default quicksearches + addChart('cf_crash_signature', 'substring', $word, $negate); } sub _handle_urls { my ($word, $negate) = @_; + return unless defined($word); + # URL field (for IP addrs, host.names, # scheme://urls) if ($word =~ m/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ |