From: Max Kanat-Alexander Date: Mon, 5 Jul 2010 23:39:24 +0000 (-0700) Subject: Bug 562014: Fix negative keyword searches like "contains none of the words" X-Git-Tag: bugzilla-3.6.2~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68744bef49a237e15df9df7bce3935d094a76bcb;p=thirdparty%2Fbugzilla.git Bug 562014: Fix negative keyword searches like "contains none of the words" to properly find bugs with *none* of the listed keywords, and also to find bugs with no keywords at all. r=LpSolit, a=LpSolit --- diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 9f13d0117b..d946d928d3 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -647,7 +647,8 @@ sub init { "^component,(?!changed)" => \&_component_nonchanged, "^product,(?!changed)" => \&_product_nonchanged, "^classification,(?!changed)" => \&_classification_nonchanged, - "^keywords,(?:equals|notequals|anyexact|anyword|allwords|nowords)" => \&_keywords_exact, + "^keywords,(?:equals|anyexact|anyword|allwords)" => \&_keywords_exact, + "^keywords,(?:notequals|notregexp|notsubstring|nowords|nowordssubstr)" => \&_multiselect_negative, "^keywords,(?!changed)" => \&_keywords_nonchanged, "^dependson,(?!changed)" => \&_dependson_nonchanged, "^blocked,(?!changed)" => \&_blocked_nonchanged, @@ -1891,7 +1892,7 @@ sub _keywords_exact { my %func_args = @_; my ($chartid, $v, $ff, $f, $t, $term, $supptables) = @func_args{qw(chartid v ff f t term supptables)}; - + my @list; my $table = "keywords_$$chartid"; foreach my $value (split(/[\s,]+/, $$v)) { @@ -2039,8 +2040,16 @@ sub _multiselect_negative { nowordssubstr => 'anywordssubstr', ); - my $table = "bug_$$f"; - $$ff = "$table.value"; + my $table; + if ($$f eq 'keywords') { + $table = "keywords LEFT JOIN keyworddefs" + . " ON keywords.keywordid = keyworddefs.id"; + $$ff = "keyworddefs.name"; + } + else { + $table = "bug_$$f"; + $$ff = "$table.value"; + } $$funcsbykey{",".$map{$$t}}($self, %func_args); $$term = "bugs.bug_id NOT IN (SELECT bug_id FROM $table WHERE $$term)";