From df405604bb856cfdce0b900d414248b48d1399d6 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Tue, 15 Feb 2011 05:48:11 +0000 Subject: [PATCH] Bug 490322: Make "allwords" work with the keywords field, again. r=glob, a=mkanat git-svn-id: svn://10.0.0.236/branches/BUGZILLA-4_0-BRANCH@261942 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Search.pm | 41 ++++++++----------- .../en/default/global/user-error.html.tmpl | 2 + .../xt/lib/Bugzilla/Test/Search/Constants.pm | 6 ++- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 802a3d3ecba..73617cc0b0f 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7554 \ No newline at end of file +7555 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Search.pm b/mozilla/webtools/bugzilla/Bugzilla/Search.pm index a06dcb4419e..025c11e8c90 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Search.pm @@ -2089,33 +2089,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/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl index bd9fb0a5b1f..f2cf053a522 100644 --- a/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl @@ -1788,6 +1788,8 @@ field [% ELSIF class == "Bugzilla::Group" %] group + [% ELSIF class == "Bugzilla::Keyword" %] + keyword [% ELSIF class == "Bugzilla::Product" %] product [% ELSIF class == "Bugzilla::Search::Recent" %] diff --git a/mozilla/webtools/bugzilla/xt/lib/Bugzilla/Test/Search/Constants.pm b/mozilla/webtools/bugzilla/xt/lib/Bugzilla/Test/Search/Constants.pm index 7fe7d0efa4e..01a27a9312e 100644 --- a/mozilla/webtools/bugzilla/xt/lib/Bugzilla/Test/Search/Constants.pm +++ b/mozilla/webtools/bugzilla/xt/lib/Bugzilla/Test/Search/Constants.pm @@ -291,7 +291,6 @@ use constant ALLWORDS_BROKEN => ( ATTACHMENT_BOOLEANS_SEARCH_BROKEN, bug_group => { contains => [1] }, cc => { contains => [1] }, - keywords => { contains => [1] }, longdesc => { contains => [1] }, work_time => { contains => [1] }, percentage_complete => { contains => [2,3,4,5] }, @@ -428,7 +427,10 @@ use constant KNOWN_BROKEN => { bug_group => { contains => [3,4,5] }, }, - 'allwordssubstr-<1>' => { ALLWORDS_BROKEN }, + 'allwordssubstr-<1>' => { + ALLWORDS_BROKEN, + keywords => { contains => [1] } + }, 'allwordssubstr-<1>,<2>' => { ATTACHMENT_BOOLEANS_SEARCH_BROKEN, percentage_complete => { contains => [1,2,3,4,5] },