]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 828344: "contains all of the words" no longer looks for all words within the...
authorByron Jones <bjones@mozilla.com>
Fri, 10 May 2013 08:18:12 +0000 (16:18 +0800)
committerByron Jones <bjones@mozilla.com>
Fri, 10 May 2013 08:18:12 +0000 (16:18 +0800)
r=LpSolit, a=LpSolit

Bugzilla/Search.pm
Bugzilla/Search/Condition.pm
Bugzilla/Search/Quicksearch.pm

index 51520bb5599f96a8f20794fb4f3c88588db4490b..a91a25b0674674810410df14b5c9c1147b230a94 100644 (file)
@@ -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 {
index 4975775af31622b804b44ebc9fb9aa7a12a4968e..eab4ab79d246c19ce566aa86247d29ebe7e11600 100644 (file)
@@ -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);
index d073720a1d34fc95faedd5aa80c09e228ce6f4fe..3133b1a6bf52aa8cb0123c9dbdb0b70bc533fa47 100644 (file)
@@ -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;
     }