[Rt-commit] rt branch, 4.6/disabled-attributes, created. rt-4.4.4-685-gdedd1625b0

? sunnavy sunnavy at bestpractical.com
Fri Jan 10 17:51:39 EST 2020


The branch, 4.6/disabled-attributes has been created
        at  dedd1625b0e10e21e59563bbd249de7eeaca9e8b (commit)

- Log -----------------------------------------------------------------
commit ccff21a6f89b985e367ad6b74be280b992cc862e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 8 06:27:31 2020 +0800

    Add Disabled column for Attributes table

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index b71b41d9d4..45644160bd 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -397,7 +397,8 @@ CREATE TABLE Attributes (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE,
         LastUpdatedBy           NUMBER(11,0) DEFAULT 0 NOT NULL,
-        LastUpdated             DATE
+        LastUpdated             DATE,
+        Disabled                NUMBER(11,0) DEFAULT 0 NOT NULL
 );
 
 CREATE INDEX Attributes1 on Attributes(Name);
diff --git a/etc/schema.Pg b/etc/schema.Pg
index eda93108df..fc32a10f2a 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -623,6 +623,7 @@ CREATE TABLE Attributes (
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
+  Disabled integer NOT NULL DEFAULT 0,
   PRIMARY KEY (id)
 
 );
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index b6e0166345..2081a62041 100644
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -446,7 +446,8 @@ CREATE TABLE Attributes (
   Creator integer NULL DEFAULT 0 ,
   Created DATETIME NULL  ,
   LastUpdatedBy integer NULL DEFAULT 0 ,
-  LastUpdated DATETIME NULL  
+  LastUpdated DATETIME NULL,
+  Disabled int2 NOT NULL DEFAULT 0
  
 ) ;
 CREATE INDEX Attributes1 on Attributes(Name);
diff --git a/etc/schema.mysql b/etc/schema.mysql
index 1d6da82c59..e1dd7d7a3b 100644
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -420,6 +420,7 @@ CREATE TABLE Attributes (
   Created DATETIME NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated DATETIME NULL  ,
+  Disabled int2 NOT NULL DEFAULT 0,
   PRIMARY KEY (id)
 ) ENGINE=InnoDB CHARACTER SET utf8;
 
diff --git a/etc/upgrade/4.5.3/schema.Oracle b/etc/upgrade/4.5.3/schema.Oracle
new file mode 100644
index 0000000000..6620584fed
--- /dev/null
+++ b/etc/upgrade/4.5.3/schema.Oracle
@@ -0,0 +1 @@
+ALTER TABLE Attributes ADD Disabled NUMBER(11,0) DEFAULT 0 NOT NULL;
diff --git a/etc/upgrade/4.5.3/schema.Pg b/etc/upgrade/4.5.3/schema.Pg
new file mode 100644
index 0000000000..b5f6ddeb21
--- /dev/null
+++ b/etc/upgrade/4.5.3/schema.Pg
@@ -0,0 +1 @@
+ALTER TABLE Attributes ADD COLUMN Disabled integer NOT NULL DEFAULT 0;
diff --git a/etc/upgrade/4.5.3/schema.SQLite b/etc/upgrade/4.5.3/schema.SQLite
new file mode 100644
index 0000000000..85227636f1
--- /dev/null
+++ b/etc/upgrade/4.5.3/schema.SQLite
@@ -0,0 +1 @@
+ALTER TABLE Attributes ADD COLUMN Disabled int2 NOT NULL DEFAULT 0;
diff --git a/etc/upgrade/4.5.3/schema.mysql b/etc/upgrade/4.5.3/schema.mysql
new file mode 100644
index 0000000000..85227636f1
--- /dev/null
+++ b/etc/upgrade/4.5.3/schema.mysql
@@ -0,0 +1 @@
+ALTER TABLE Attributes ADD COLUMN Disabled int2 NOT NULL DEFAULT 0;
diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index e8d1b47188..92af602f87 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -622,7 +622,8 @@ sub _CoreAccessible {
                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         LastUpdated =>
                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
-
+        Disabled =>
+                {read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'},
  }
 };
 
diff --git a/lib/RT/Attributes.pm b/lib/RT/Attributes.pm
index ecc4fe4d7a..5a1c7a9b8c 100644
--- a/lib/RT/Attributes.pm
+++ b/lib/RT/Attributes.pm
@@ -74,6 +74,11 @@ use RT::Attribute;
 
 sub Table { 'Attributes'}
 
+sub _Init {
+    my $self = shift;
+    $self->{'with_disabled_column'} = 1;
+    return $self->SUPER::_Init(@_);
+}
 
 sub _DoSearch {
     my $self = shift;

commit 0462a9ea50af58d514dc900f02c4219b1ce2cc1c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 8 23:24:45 2020 +0800

    Disable instead of deleting to keep more attribute history

diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index 92af602f87..fd92afd781 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -377,7 +377,8 @@ sub Delete {
         return (0,$self->loc('Permission Denied'));
     }
 
-    return($self->SUPER::Delete(@_));
+    my ( $ret, $msg ) = $self->SetDisabled(1);
+    return wantarray ? ( $ret, $msg ) : $ret;
 }
 
 

commit 3f23b19eaf46b2ba5d0c41dfa5075fbbb7d7ac32
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jan 8 23:27:23 2020 +0800

    Update attribute tests for the change of delete => disable

diff --git a/t/api/attribute.t b/t/api/attribute.t
index 417f015281..568a3ec246 100644
--- a/t/api/attribute.t
+++ b/t/api/attribute.t
@@ -34,7 +34,7 @@ is ($attr2->SubValue('Format'), 'This is a format');
 $attr2->Delete;
 my $attr3 = RT::Attribute->new(RT->SystemUser);
 ($id) = $attr3->Load($id);
-is ($id, 0);
+is ($attr3->Disabled, 1);
 
 
 }

commit dedd1625b0e10e21e59563bbd249de7eeaca9e8b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jan 10 05:55:41 2020 +0800

    Don't load disabled SharedSetting records like Dashboards
    
    This is to retain previous behavior. Disabled attributes on the other
    hand, could still be loaded so we can investigate data easily.

diff --git a/lib/RT/SharedSetting.pm b/lib/RT/SharedSetting.pm
index d41ce65fa5..b4c0582c70 100644
--- a/lib/RT/SharedSetting.pm
+++ b/lib/RT/SharedSetting.pm
@@ -105,7 +105,7 @@ sub Load {
     if ($object) {
         $self->{'Attribute'} = RT::Attribute->new($self->CurrentUser);
         $self->{'Attribute'}->Load( $id );
-        if ($self->{'Attribute'}->Id) {
+        if ($self->{'Attribute'}->Id && !$self->{'Attribute'}->Disabled) {
             $self->{'Id'} = $self->{'Attribute'}->Id;
             $self->{'Privacy'} = $privacy;
             $self->PostLoad();
@@ -143,7 +143,7 @@ sub LoadById {
     my $attr = RT::Attribute->new($self->CurrentUser);
     my ($ok, $msg) = $attr->LoadById($id);
 
-    if (!$ok) {
+    if (!$ok || $attr->Disabled) {
         return wantarray ? (0, $self->loc("Failed to load [_1] [_2]: [_3]", $self->ObjectName, $id, $msg)) : 0;
     }
 

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


More information about the rt-commit mailing list