summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-05-10 10:18:12 +0200
committerByron Jones <bjones@mozilla.com>2013-05-10 10:18:12 +0200
commita7859e10d9456dbe17373ebfdd1a22cc88a4c754 (patch)
tree43f652565a11cc595f4670e28bbf0761755c7831 /Bugzilla
parent2baddffae7097f9c4181b9115489017f90454292 (diff)
downloadbugzilla-a7859e10d9456dbe17373ebfdd1a22cc88a4c754.tar.gz
bugzilla-a7859e10d9456dbe17373ebfdd1a22cc88a4c754.tar.xz
Bug 828344: "contains all of the words" no longer looks for all words within the same comment or flag
r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Search.pm90
-rw-r--r--Bugzilla/Search/Condition.pm9
-rw-r--r--Bugzilla/Search/Quicksearch.pm11
3 files changed, 58 insertions, 52 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 51520bb55..a91a25b06 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -1817,6 +1817,7 @@ sub _handle_chart {
joins => [],
bugs_table => 'bugs',
table_suffix => '',
+ condition => $condition,
);
$clause->update_search_args(\%search_args);
@@ -2725,59 +2726,50 @@ sub _multiselect_multiple {
sub _flagtypes_nonchanged {
my ($self, $args) = @_;
- my ($chart_id, $operator, $value, $joins, $bugs_table) =
- @$args{qw(chart_id operator value joins bugs_table)};
+ my ($chart_id, $operator, $value, $joins, $bugs_table, $condition) =
+ @$args{qw(chart_id operator value joins bugs_table condition)};
my $dbh = Bugzilla->dbh;
- my $join;
-
- # join to the attachments table
- my $attach_table = "attachments_$chart_id";
- $join = {
- table => 'attachments',
- as => $attach_table,
- from => "$bugs_table.bug_id",
- to => "bug_id",
- extra => [ ($self->_user->is_insider ? '' : "$attach_table.isprivate = 0") ],
- };
- push(@$joins, $join);
- # join to the flags table
- my $flags_table = "flags_$chart_id";
- $join = {
- table => 'flags',
- as => $flags_table,
- from => "$bugs_table.bug_id",
- to => "bug_id",
- extra => [ "($flags_table.attach_id = $attach_table.attach_id " .
- " OR $flags_table.attach_id IS NULL)" ],
- };
- push(@$joins, $join);
-
- # join to the flagtypes table
- my $flagtypes_table = "flagtypes_$chart_id";
- $join = {
- table => 'flagtypes',
- as => $flagtypes_table,
- from => "$flags_table.type_id",
- to => "id",
- };
- push(@$joins, $join);
+ # For 'not' operators, we need to negate the whole term.
+ # If you search for "Flags" (does not contain) "approval+" we actually want
+ # to return *bugs* that don't contain an approval+ flag. Without rewriting
+ # the negation we'll search for *flags* which don't contain approval+.
+ if ($operator =~ s/^not//) {
+ $args->{operator} = $operator;
+ $condition->operator($operator);
+ $condition->negate(1);
+ }
- # join to the profiles table for the requestee
- my $flag_profile_table = "flag_profiles_$chart_id";
- $join = {
- table => 'profiles',
- as => $flag_profile_table,
- from => "$flags_table.requestee_id",
- to => "userid",
+ my $subselect_args = {
+ chart_id => $chart_id,
+ sequence => $chart_id,
+ field => 'flagtypes.name',
+ full_field => $dbh->sql_string_concat("flagtypes_$chart_id.name", "flags_$chart_id.status"),
+ operator => $operator,
+ value => $value,
+ all_values => $value,
+ quoted => $dbh->quote($value),
+ joins => [],
+ bugs_table => "bugs_$chart_id",
};
- push(@$joins, $join);
-
- $args->{full_field} = $dbh->sql_string_concat("$flagtypes_table.name",
- "$flags_table.status",
- "COALESCE($flag_profile_table.login_name, '')");
-
- $self->_do_operator_function($args);
+ $self->_do_operator_function($subselect_args);
+ my $subselect_term = $subselect_args->{term};
+
+ # don't call build_subselect as this must run as a true sub-select
+ $args->{term} = "EXISTS (
+ SELECT 1
+ FROM $bugs_table bugs_$chart_id
+ LEFT JOIN attachments AS attachments_$chart_id
+ ON bugs_$chart_id.bug_id = attachments_$chart_id.bug_id
+ LEFT JOIN flags AS flags_$chart_id
+ ON bugs_$chart_id.bug_id = flags_$chart_id.bug_id
+ AND (flags_$chart_id.attach_id = attachments_$chart_id.attach_id
+ OR flags_$chart_id.attach_id IS NULL)
+ LEFT JOIN flagtypes AS flagtypes_$chart_id
+ ON flags_$chart_id.type_id = flagtypes_$chart_id.id
+ WHERE bugs_$chart_id.bug_id = $bugs_table.bug_id
+ AND $subselect_term
+ )";
}
sub _multiselect_nonchanged {
diff --git a/Bugzilla/Search/Condition.pm b/Bugzilla/Search/Condition.pm
index 4975775af..eab4ab79d 100644
--- a/Bugzilla/Search/Condition.pm
+++ b/Bugzilla/Search/Condition.pm
@@ -21,9 +21,16 @@ sub new {
}
sub field { return $_[0]->{field} }
-sub operator { return $_[0]->{operator} }
sub value { return $_[0]->{value} }
+sub operator {
+ my ($self, $value) = @_;
+ if (@_ == 2) {
+ $self->{operator} = $value;
+ }
+ return $self->{operator};
+}
+
sub fov {
my ($self) = @_;
return ($self->field, $self->operator, $self->value);
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm
index d073720a1..3133b1a6b 100644
--- a/Bugzilla/Search/Quicksearch.pm
+++ b/Bugzilla/Search/Quicksearch.pm
@@ -364,8 +364,15 @@ sub _handle_field_names {
my ($or_operand, $negate, $unknownFields, $ambiguous_fields) = @_;
# Flag and requestee shortcut
- if ($or_operand =~ /^(?:flag:)?([^\?]+\?[^\?]*)$/) {
- addChart('flagtypes.name', 'substring', $1, $negate);
+ 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);
+ }
return 1;
}