[Rt-commit] rt branch, 4.4/disabled-custom-field-search, created. rt-4.4.3-59-ge961e6d06

? sunnavy sunnavy at bestpractical.com
Fri Oct 5 17:07:37 EDT 2018


The branch, 4.4/disabled-custom-field-search has been created
        at  e961e6d06da4d1c1a31cf6ee2b7a3ec5fc15b0b8 (commit)

- Log -----------------------------------------------------------------
commit e72e1a109d679e4dae3163556811247142143229
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 6 04:56:22 2018 +0800

    Do not search disabled custom fields
    
    Fixes: I#33972

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 01e265127..bab762b12 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -379,7 +379,7 @@ sub _CustomFieldJoin {
         $self->Limit(
             LEFTJOIN        => $ocfvalias,
             FIELD           => 'CustomField',
-            VALUE           => $cf->id,
+            VALUE           => $cf->Disabled ? 0 : $cf->id,
             ENTRYAGGREGATOR => 'AND'
         );
     }
@@ -435,6 +435,12 @@ sub _CustomFieldJoinByName {
         CASESENSITIVE   => 0,
         VALUE           => $cf,
     );
+    $self->Limit(
+        LEFTJOIN        => $CFs,
+        ENTRYAGGREGATOR => 'AND',
+        FIELD           => 'Disabled',
+        VALUE           => 0,
+    );
 
     my $ocfvalias = $self->Join(
         TYPE   => 'LEFT',

commit e961e6d06da4d1c1a31cf6ee2b7a3ec5fc15b0b8
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 6 05:02:13 2018 +0800

    Test ticket search with disabled custom fields

diff --git a/t/ticket/search.t b/t/ticket/search.t
index 2845dd8bc..9cd080981 100644
--- a/t/ticket/search.t
+++ b/t/ticket/search.t
@@ -289,6 +289,29 @@ $tix = RT::Tickets->new(RT->SystemUser);
 $tix->FromSQL("CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3' OR CF.SearchTest2 = 'bar1' OR CF.SearchTest2 = 'bar2'");
 is($tix->Count, 3, "is cf1 or is cf1 or is cf2 or is cf2");
 
+# tests with disabled CF
+$cf->SetDisabled(1);
+ok($cf->Disabled, 'cf1 is disabled');
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("CF.SearchTest = 'foo1'");
+is($tix->Count, 0, "disabled cf1 with name");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("CF." . $cf->id . " = 'foo1'");
+is($tix->Count, 0, "disabled cf1 with id");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("CF.SearchTest != 'foo1'");
+is($tix->Count, 7, "disabled cf1 with name and negative operator");
+
+$tix = RT::Tickets->new(RT->SystemUser);
+$tix->FromSQL("CF." . $cf->id . " != 'foo1'");
+is($tix->Count, 7, "disabled cf1 with id and negative operator");
+
+$cf->SetDisabled(0);
+ok(!$cf->Disabled, 'cf1 is enabled');
+
 # tests with lower cased NULL
 $tix = RT::Tickets->new(RT->SystemUser);
 $tix->FromSQL('Requestor.Name IS null');

-----------------------------------------------------------------------


More information about the rt-commit mailing list