diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2011-02-14 21:45:10 -0800 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2011-02-14 21:45:10 -0800 |
commit | 80a0dd45efc6a1655a99245729262c6242ad79f3 (patch) | |
tree | d1e193351dca30f7ae104089afeedaca9e4a2da1 | |
parent | Bug 480044: Use dashes instead of colons to separate bug IDs in the BUGLIST c... (diff) | |
download | bugzilla-80a0dd45efc6a1655a99245729262c6242ad79f3.tar.gz bugzilla-80a0dd45efc6a1655a99245729262c6242ad79f3.tar.bz2 bugzilla-80a0dd45efc6a1655a99245729262c6242ad79f3.zip |
Bug 490322: Make "allwords" work with the keywords field, again.
r=glob, a=mkanat
-rw-r--r-- | Bugzilla/Search.pm | 41 | ||||
-rw-r--r-- | template/en/default/global/user-error.html.tmpl | 2 |
2 files changed, 19 insertions, 24 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 4340025a8..c373f974d 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1892,33 +1892,26 @@ sub _keywords_exact { my ($chartid, $v, $ff, $f, $t, $term, $supptables) = @func_args{qw(chartid v ff f t term supptables)}; - my @list; + my @keyword_ids; + foreach my $word (split(/[\s,]+/, $$v)) { + next if $word eq ''; + my $keyword = Bugzilla::Keyword->check($word); + push(@keyword_ids, $keyword->id); + } + my $table = "keywords_$$chartid"; - foreach my $value (split(/[\s,]+/, $$v)) { - if ($value eq '') { - next; - } - my $keyword = new Bugzilla::Keyword({name => $value}); - if ($keyword) { - push(@list, "$table.keywordid = " . $keyword->id); - } - else { - ThrowUserError("unknown_keyword", - { keyword => $$v }); - } + my $id_field = "$table.keywordid"; + if ($$t eq 'anywords' or $$t eq 'anyexact') { + my $dbh = Bugzilla->dbh; + $$term = $dbh->sql_in($id_field, \@keyword_ids); } - my $haveawordterm; - if (@list) { - $haveawordterm = "(" . join(' OR ', @list) . ")"; - if ($$t eq "anywords") { - $$term = $haveawordterm; - } elsif ($$t eq "allwords") { - $self->_allwords; - if ($$term && $haveawordterm) { - $$term = "(($$term) AND $haveawordterm)"; - } - } + if ($$t eq 'allwords') { + my @terms = + map { "bugs.bug_id IN (SELECT bug_id FROM keywords WHERE keywordid = $_)" } @keyword_ids; + $$term = join(' AND ', @terms); + return; } + if ($$term) { push(@$supptables, "LEFT JOIN keywords AS $table " . "ON $table.bug_id = bugs.bug_id"); diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 558466730..28bb67d60 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1811,6 +1811,8 @@ field [% ELSIF class == "Bugzilla::Group" %] group + [% ELSIF class == "Bugzilla::Keyword" %] + keyword [% ELSIF class == "Bugzilla::Product" %] product [% ELSIF class == "Bugzilla::Search::Saved" %] |