]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 638489 - Make all boolean charts work with longdescs.isprivate
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Thu, 3 Mar 2011 18:24:16 +0000 (10:24 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Thu, 3 Mar 2011 18:24:16 +0000 (10:24 -0800)
r=mkanat, a=mkanat (module owner)

Bugzilla/Search.pm
template/en/default/global/user-error.html.tmpl
xt/lib/Bugzilla/Test/Search/Constants.pm

index 81b459ee51ea53181913e6cc46a63fc123a95ae0..2bbd4e451d6a5133ee3217cb667ebf686f00c171 100644 (file)
@@ -309,9 +309,7 @@ use constant OPERATOR_FIELD_OVERRIDE => {
         changedto     => \&_invalid_combination,
         _default      => \&_long_descs_count,
     },
-    'longdescs.isprivate' => {
-        _default => \&_longdescs_isprivate,
-    },
+    'longdescs.isprivate' => MULTI_SELECT_OVERRIDE,
     owner_idle_time => {
         greaterthan   => \&_owner_idle_time_greater_less,
         greaterthaneq => \&_owner_idle_time_greater_less,
@@ -2269,25 +2267,6 @@ sub _content_matches {
     COLUMNS->{'relevance'}->{name} = $select_term;
 }
 
-sub _join_longdescs {
-    my ($self, $args) = @_;
-    my ($chart_id, $joins) = @$args{qw(chart_id joins)};
-    
-    my $table = "longdescs_$chart_id";
-    my $extra = $self->_user->is_insider ? [] : ["$table.isprivate = 0"];
-    my $join = {
-        table => 'longdescs',
-        as    => $table,
-        extra => $extra,
-    };
-    # We only want to do an INNER JOIN if we're not checking isprivate.
-    # Otherwise we'd exclude all bugs with only private comments from
-    # the search entirely.
-    $join->{join} = 'INNER' if $self->_user->is_insider;
-    push(@$joins, $join);
-    return $table;
-}
-
 sub _long_descs_count {
     my ($self, $args) = @_;
     my ($chart_id, $joins) = @$args{qw(chart_id joins)};
@@ -2302,12 +2281,6 @@ sub _long_descs_count {
     $args->{full_field} = "${table}.num";
 }
 
-sub _longdescs_isprivate {
-    my ($self, $args) = @_;
-    my $table = $self->_join_longdescs($args);
-    $args->{full_field} = "$table.isprivate";
-}
-
 sub _work_time_changedby {
     my ($self, $args) = @_;
     my ($chart_id, $joins, $value) = @$args{qw(chart_id joins value)};
@@ -2588,11 +2561,12 @@ sub _multiselect_multiple {
         push(@terms, $self->_multiselect_term($args));
     }
     
+    # The spacing in the joins helps make the resulting SQL more readable.
     if ($operator =~ /^any/) {
-        $args->{term} = join(" OR ", @terms);
+        $args->{term} = join("\n        OR ", @terms);
     }
     else {
-        $args->{term} = join(" AND ", @terms);
+        $args->{term} = join("\n        AND ", @terms);
     }
 }
 
@@ -2633,6 +2607,14 @@ sub _multiselect_table {
         $args->{full_field} = 'thetext';
         return "longdescs";
     }
+    elsif ($field eq 'longdescs.isprivate') {
+        ThrowUserError('auth_failure', { action => 'search',
+                                         object => 'bug_fields',
+                                         field => 'longdescs.isprivate' })
+            if !$self->_user->is_insider;
+        $args->{full_field} = 'isprivate';
+        return "longdescs";
+    }
     my $table = "bug_$field";
     $args->{full_field} = "bug_$field.value";
     return $table;
index 47219e3d99486820c2fa4d87c66a81e447998dc1..16b66ca84830332e1821d9f8aa8f8ff0062b3b31 100644 (file)
       run
     [% ELSIF action == "schedule" %]
       schedule
+    [% ELSIF action == "search" %]
+      search
     [% ELSIF action == "use" %]
       use
     [% ELSIF action == "approve" %]
       [% END %]
     [% ELSIF object == "bugs" %]
       [%+ terms.bugs %]
+    [% ELSIF object == "bug_fields" %]
+      the [% field_descs.$field FILTER html %] field
     [% ELSIF object == "charts" %]
       the "New Charts" feature
     [% ELSIF object == "classifications" %]
index ed7ff8f741c7216fd38cd47cadf04a49165d3e65..227203bc73ea6c6d2b446456a09e0169bd31c756 100644 (file)
@@ -214,7 +214,6 @@ use constant NEGATIVE_BROKEN => (
     'attachments.mimetype'    => { contains => [5] },
     bug_file_loc => { contains => [5] },
     deadline     => { contains => [5] },
-    'longdescs.isprivate'   => { contains => [1] },
     # Custom fields are busted because they can be NULL.
     FIELD_TYPE_FREETEXT, { contains => [5] },
     FIELD_TYPE_BUG_ID,   { contains => [5] },
@@ -248,15 +247,9 @@ use constant ALLWORDS_BROKEN => (
 # nowords and nowordssubstr have these broken tests in common.
 #
 # flagtypes.name doesn't match bugs without flags.
-# longdescs.isprivate actually works properly in
-# terms of excluding bug 1 (since we exclude all values in the search,
-# on our test), but still fails at including bug 5.
-# The longdesc* fields, coincidentally, work completely
-# correctly, possibly because there's only one comment on bug 5.
 use constant NOWORDS_BROKEN => (
     NEGATIVE_BROKEN,
     'flagtypes.name' => { contains => [5] },
-    'longdescs.isprivate' => {},
 );
 
 # Fields that don't generally work at all with changed* searches, but
@@ -311,18 +304,6 @@ use constant KNOWN_BROKEN => {
     notsubstring => { NEGATIVE_BROKEN },
     notregexp    => { NEGATIVE_BROKEN },
 
-    # longdescs.isprivate matches if any comment matches, instead of if all
-    # comments match. (Commenter is probably
-    # also broken in this way, but all our comments come from the same user.) 
-    lessthan   => {
-        'longdescs.isprivate'   => { contains => [1] },
-    },
-    # The lessthaneq tests are broken for the same reasons, but they work
-    # slightly differently so they have a different set of broken tests.
-    lessthaneq => {
-        'longdescs.isprivate' => { contains => [1] },
-    },
-
     greaterthan   => { GREATERTHAN_BROKEN },
     greaterthaneq => { GREATERTHAN_BROKEN },
 
@@ -441,7 +422,6 @@ use constant COMMON_BROKEN_NOT => (
     "bug_file_loc"            => { contains => [5] },
     "deadline"                => { contains => [5] },
     "flagtypes.name"          => { contains => [5] },
-    "longdescs.isprivate"     => { contains => [1] },
     FIELD_TYPE_BUG_ID,           { contains => [5] },
     FIELD_TYPE_DATETIME,         { contains => [5] },
     FIELD_TYPE_FREETEXT,         { contains => [5] },
@@ -486,7 +466,6 @@ use constant BROKEN_NOT => {
         'attach_data.thedata' => { contains => [5] },
         cc => { },
         'flagtypes.name'      => { contains => [5] },
-        'longdescs.isprivate' => { },
     },
     allwordssubstr => {
         COMMON_BROKEN_NOT,
@@ -494,7 +473,6 @@ use constant BROKEN_NOT => {
     },
     'allwordssubstr-<1>,<2>' => {
         cc => { },
-        "longdescs.isprivate" => { },
     },
     anyexact => {
         COMMON_BROKEN_NOT,
@@ -560,11 +538,9 @@ use constant BROKEN_NOT => {
     },
     lessthan => {
         COMMON_BROKEN_NOT,
-        'longdescs.isprivate' => { },
     },
     lessthaneq => {
         COMMON_BROKEN_NOT,
-        'longdescs.isprivate' => { },
     },
     notequals      => { NEGATIVE_BROKEN_NOT },
     notregexp      => { NEGATIVE_BROKEN_NOT },
@@ -828,7 +804,7 @@ use constant TESTS => {
               cclist_accessible        => { value => 1, contains => [2,3,4,5] },
               reporter_accessible      => { value => 1, contains => [2,3,4,5] },
               'longdescs.count'        => { value => 3, contains => [2,3,4,5] },
-              'longdescs.isprivate'    => { value => 1, contains => [2,3,4,5] },
+              'longdescs.isprivate'    => { value => 1, contains => [1,2,3,4,5] },
               everconfirmed            => { value => 1, contains => [2,3,4,5] },
               creation_ts => { value => '2037-01-02', contains => [1,5] },
               delta_ts    => { value => '2037-01-02', contains => [1,5] },
@@ -852,7 +828,7 @@ use constant TESTS => {
               cclist_accessible        => { value => 0, contains => [2,3,4,5] },
               reporter_accessible      => { value => 0, contains => [2,3,4,5] },
               'longdescs.count'        => { value => 2, contains => [2,3,4,5] },
-              'longdescs.isprivate'    => { value => 0, contains => [2,3,4,5] },
+              'longdescs.isprivate'    => { value => -1, contains => [] },
               everconfirmed            => { value => 0, contains => [2,3,4,5] },
               blocked   => { contains => [1,2] },
               dependson => { contains => [1,3] },
@@ -932,7 +908,9 @@ use constant TESTS => {
           override => {
               dependson => { value => '<1-id> <3-id>', contains => [] },
               # bug 3 has the value "21" here, so matches "2,1"
-              percentage_complete => { value => '<2>,<3>', contains => [3] }
+              percentage_complete => { value => '<2>,<3>', contains => [3] },
+              # 1 0 matches bug 1, which has both public and private comments.
+             'longdescs.isprivate' => { contains => [1] },              
           }
         },
     ],
@@ -966,7 +944,9 @@ use constant TESTS => {
           override => { MULTI_BOOLEAN_OVERRIDE } },
         { contains => [], value => '<1> <2>',
           override => {
-            dependson => { contains => [], value => '<2-id> <3-id>' }
+            dependson => { contains => [], value => '<2-id> <3-id>' },
+            # 1 0 matches bug 1, which has both public and private comments.
+            'longdescs.isprivate' => { contains => [1] },
           }
         },
     ],