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
This commit is contained in:
mkanat%bugzilla.org 2011-02-15 05:48:11 +00:00
parent 3e969d8852
commit df405604bb
4 changed files with 24 additions and 27 deletions

View File

@ -1 +1 @@
7554
7555

View File

@ -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");

View File

@ -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" %]

View File

@ -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] },