[Rt-commit] rt branch, 4.2/deprecate-type-column-in-groups, created. rt-4.1.8-151-gf704418

Ruslan Zakirov ruz at bestpractical.com
Fri Apr 19 10:12:52 EDT 2013


The branch, 4.2/deprecate-type-column-in-groups has been created
        at  f704418a7629afbf57138ba6936066aaff0b7d30 (commit)

- Log -----------------------------------------------------------------
commit cf769404423246258255b926e4a54be1648a4f61
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Apr 19 13:00:14 2013 +0400

    call SUPER method later and in one place
    
    would allow us to inject %ARGS checking after
    existing sanity checks

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index cd1c089..ff683f9 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -271,7 +271,6 @@ sub Limit {
 
     if ($ARGS{FUNCTION}) {
         ($ARGS{ALIAS}, $ARGS{FIELD}) = split /\./, delete $ARGS{FUNCTION}, 2;
-        $self->SUPER::Limit(%ARGS);
     } elsif ($ARGS{FIELD} =~ /\W/
           or $ARGS{OPERATOR} !~ /^(=|<|>|!=|<>|<=|>=
                                   |(NOT\s*)?LIKE
@@ -281,15 +280,14 @@ sub Limit {
                                   |(NOT\s*)?IN
                                   |\@\@)$/ix) {
         $RT::Logger->crit("Possible SQL injection attack: $ARGS{FIELD} $ARGS{OPERATOR}");
-        $self->SUPER::Limit(
+        %ARGS = (
             %ARGS,
             FIELD    => 'id',
             OPERATOR => '<',
             VALUE    => '0',
         );
-    } else {
-        $self->SUPER::Limit(%ARGS);
     }
+    return $self->SUPER::Limit( %ARGS );
 }
 
 =head2 ItemsOrderBy

commit f704418a7629afbf57138ba6936066aaff0b7d30
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Apr 15 20:40:41 2013 +0400

    deprecate Groups.Type column
    
    Groups records were using either Name or Type, actually only
    user defined groups were using Name.
    
    We deprecate Type in favor of Name, but keep it in DB for 4.2
    and remove in 4.4. Attempts to read Type, set Type, search by
    Type throw deprecation warning, but still work. Also, Type and
    Name are kept equal.

diff --git a/etc/upgrade/4.1.10/schema.Oracle b/etc/upgrade/4.1.10/schema.Oracle
new file mode 100644
index 0000000..96869c6
--- /dev/null
+++ b/etc/upgrade/4.1.10/schema.Oracle
@@ -0,0 +1,3 @@
+UPDATE Groups SET Name = Type
+WHERE LOWER(Domain) IN ('aclequivalence', 'systeminternal') OR LOWER(Domain) LIKE '%-role';
+
diff --git a/etc/upgrade/4.1.10/schema.Pg b/etc/upgrade/4.1.10/schema.Pg
new file mode 100644
index 0000000..96869c6
--- /dev/null
+++ b/etc/upgrade/4.1.10/schema.Pg
@@ -0,0 +1,3 @@
+UPDATE Groups SET Name = Type
+WHERE LOWER(Domain) IN ('aclequivalence', 'systeminternal') OR LOWER(Domain) LIKE '%-role';
+
diff --git a/etc/upgrade/4.1.10/schema.SQLite b/etc/upgrade/4.1.10/schema.SQLite
new file mode 100644
index 0000000..9ea6a91
--- /dev/null
+++ b/etc/upgrade/4.1.10/schema.SQLite
@@ -0,0 +1,3 @@
+UPDATE Groups SET Name = Type
+WHERE Domain IN ('ACLEquivalence', 'SystemInternal') OR Domain LIKE '%-Role';
+
diff --git a/etc/upgrade/4.1.10/schema.mysql b/etc/upgrade/4.1.10/schema.mysql
new file mode 100644
index 0000000..a429007
--- /dev/null
+++ b/etc/upgrade/4.1.10/schema.mysql
@@ -0,0 +1,2 @@
+UPDATE Groups SET Name = Type
+WHERE Domain IN ('ACLEquivalence', 'SystemInternal') OR Domain LIKE '%-Role';
\ No newline at end of file
diff --git a/etc/upgrade/4.1.4/content b/etc/upgrade/4.1.4/content
index b3f59f6..b320695 100644
--- a/etc/upgrade/4.1.4/content
+++ b/etc/upgrade/4.1.4/content
@@ -11,7 +11,7 @@ push @Final, sub {
         my $group       = RT::Group->new( RT->SystemUser );
         my ($ok, $msg)  = $group->LoadRoleGroup(
             Object  => RT->System,
-            Type    => $role,
+            Name    => $role,
         );
 
         unless ($group->id) {
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 11f7e66..69e730f 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -190,23 +190,23 @@ sub SelfDescription {
         return $self->loc("group '[_1]'",$self->Name);
     }
     elsif ($self->Domain eq 'RT::System-Role') {
-        return $self->loc("system [_1]",$self->Type);
+        return $self->loc("system [_1]",$self->Name);
     }
     elsif ($self->Domain eq 'RT::Queue-Role') {
         my $queue = RT::Queue->new($self->CurrentUser);
         $queue->Load($self->Instance);
-        return $self->loc("queue [_1] [_2]",$queue->Name, $self->Type);
+        return $self->loc("queue [_1] [_2]",$queue->Name, $self->Name);
     }
     elsif ($self->Domain eq 'RT::Ticket-Role') {
-        return $self->loc("ticket #[_1] [_2]",$self->Instance, $self->Type);
+        return $self->loc("ticket #[_1] [_2]",$self->Instance, $self->Name);
     }
     elsif ($self->RoleClass) {
         my $class = lc $self->RoleClass;
            $class =~ s/^RT:://i;
-        return $self->loc("[_1] #[_2] [_3]", $self->loc($class), $self->Instance, $self->Type);
+        return $self->loc("[_1] #[_2] [_3]", $self->loc($class), $self->Instance, $self->Name);
     }
     elsif ($self->Domain eq 'SystemInternal') {
-        return $self->loc("system group '[_1]'",$self->Type);
+        return $self->loc("system group '[_1]'",$self->Name);
     }
     else {
         return $self->loc("undescribed group [_1]",$self->Id);
@@ -283,7 +283,7 @@ sub LoadACLEquivalenceGroup {
 
     return $self->LoadByCols(
         Domain   => 'ACLEquivalence',
-        Type     => 'UserEquiv',
+        Name     => 'UserEquiv',
         Instance => $principal,
     );
 }
@@ -305,13 +305,13 @@ sub LoadSystemInternalGroup {
 
     return $self->LoadByCols(
         Domain => 'SystemInternal',
-        Type   => $identifier,
+        Name   => $identifier,
     );
 }
 
 =head2 LoadRoleGroup
 
-Takes a paramhash of Object and Type and attempts to load the suitable role
+Takes a paramhash of Object and Name and attempts to load the suitable role
 group for said object.
 
 =cut
@@ -320,7 +320,7 @@ sub LoadRoleGroup {
     my $self = shift;
     my %args = (
         Object  => undef,
-        Type    => undef,
+        Name    => undef,
         @_
     );
 
@@ -337,7 +337,7 @@ sub LoadRoleGroup {
 }
 
 
-=head2 LoadTicketRoleGroup  { Ticket => TICKET_ID, Type => TYPE }
+=head2 LoadTicketRoleGroup  { Ticket => TICKET_ID, Name => TYPE }
 
 Deprecated in favor of L</LoadRoleGroup> or L<RT::Record/RoleGroup>.
 
@@ -347,17 +347,18 @@ sub LoadTicketRoleGroup {
     my $self = shift;
     my %args = (
         Ticket => '0',
-        Type => undef,
+        Name => undef,
         @_,
     );
     RT->Deprecated(
         Instead => "RT::Group->LoadRoleGroup or RT::Ticket->RoleGroup",
         Remove => "4.4",
     );
+    $args{'Name'} = $args{'Type'} if exists $args{'Type'};
     $self->LoadByCols(
         Domain   => 'RT::Ticket-Role',
         Instance => $args{'Ticket'},
-        Type     => $args{'Type'},
+        Name     => $args{'Name'},
     );
 }
 
@@ -373,23 +374,24 @@ sub LoadQueueRoleGroup {
     my $self = shift;
     my %args = (
         Queue => undef,
-        Type => undef,
+        Name => undef,
         @_,
     );
     RT->Deprecated(
         Instead => "RT::Group->LoadRoleGroup or RT::Queue->RoleGroup",
         Remove => "4.4",
     );
+    $args{'Name'} = $args{'Type'} if exists $args{'Type'};
     $self->LoadByCols(
         Domain   => 'RT::Queue-Role',
         Instance => $args{'Queue'},
-        Type     => $args{'Type'},
+        Name     => $args{'Name'},
     );
 }
 
 
 
-=head2 LoadSystemRoleGroup  Type
+=head2 LoadSystemRoleGroup  Name
 
 Deprecated in favor of L</LoadRoleGroup> or L<RT::Record/RoleGroup>.
 
@@ -404,10 +406,20 @@ sub LoadSystemRoleGroup {
     );
     $self->LoadByCols(
         Domain => 'RT::System-Role',
-        Type => $type
+        Name => $type
     );
 }
 
+sub LoadByCols {
+    my $self = shift;
+    my %args = ( @_ );
+    if ( exists $args{'Type'} ) {
+        RT->Deprecated( Instead => 'Name', Arguments => 'Type', Remove => '4.4' );
+        $args{'Name'} = $args{'Type'};
+    }
+    return $self->SUPER::LoadByCols( %args );
+}
+
 
 
 =head2 Create
@@ -439,12 +451,17 @@ sub _Create {
         Name        => undef,
         Description => undef,
         Domain      => undef,
-        Type        => undef,
         Instance    => '0',
         InsideTransaction => undef,
         _RecordTransaction => 1,
         @_
     );
+    if ( $args{'Type'} ) {
+        RT->Deprecated( Instead => 'Name', Arguments => 'Type', Remove => '4.4' );
+        $args{'Name'} = $args{'Type'};
+    } else {
+        $args{'Type'} = $args{'Name'};
+    }
 
     # Enforce uniqueness on user defined group names
     if ($args{'Domain'} and $args{'Domain'} eq 'UserDefined') {
@@ -522,7 +539,7 @@ sub CreateUserDefinedGroup {
         return ( 0, $self->loc('Permission Denied') );
     }
 
-    return($self->_Create( Domain => 'UserDefined', Type => '', Instance => '', @_));
+    return($self->_Create( Domain => 'UserDefined', Instance => '', @_));
 }
 
 =head2 ValidateName VALUE
@@ -576,8 +593,7 @@ sub _CreateACLEquivalenceGroup {
     my $princ = shift;
  
       my $id = $self->_Create( Domain => 'ACLEquivalence', 
-                           Type => 'UserEquiv',
-                           Name => 'User '. $princ->Object->Id,
+                           Name => 'UserEquiv',
                            Description => 'ACL equiv. for user '.$princ->Object->Id,
                            Instance => $princ->Id,
                            InsideTransaction => 1,
@@ -617,7 +633,7 @@ Takes a paramhash of:
 
 =over 4
 
-=item Type
+=item Name
 
 Required.  RT's core role types are C<Requestor>, C<Cc>, C<AdminCc>, and
 C<Owner>.  Extensions may add their own.
@@ -660,7 +676,7 @@ Message should contain an error string.
 sub CreateRoleGroup {
     my $self = shift;
     my %args = ( Instance => undef,
-                 Type     => undef,
+                 Name     => undef,
                  Domain   => undef,
                  Object   => undef,
                  InsideTransaction => 1,
@@ -678,10 +694,10 @@ sub CreateRoleGroup {
     }
 
     unless ($self->ValidateRoleGroup(%args)) {
-        return ( 0, $self->loc("Invalid Group Type and Domain") );
+        return ( 0, $self->loc("Invalid Group Name and Domain") );
     }
 
-    my %create = map { $_ => $args{$_} } qw(Domain Instance Type);
+    my %create = map { $_ => $args{$_} } qw(Domain Instance Name);
 
     my $duplicate = RT::Group->new( RT->SystemUser );
     $duplicate->LoadByCols( %create );
@@ -725,12 +741,12 @@ registered role on the specified Domain.  Otherwise returns false.
 sub ValidateRoleGroup {
     my $self = shift;
     my %args = (@_);
-    return 0 unless $args{Domain} and $args{Type};
+    return 0 unless $args{Domain} and ($args{Type} or $args{'Name'});
 
     my $class = $self->RoleClass($args{Domain});
     return 0 unless $class;
 
-    return $class->HasRole($args{Type});
+    return $class->HasRole($args{Type}||$args{'Name'});
 }
 
 =head2 SingleMemberRoleGroup
@@ -741,7 +757,7 @@ sub SingleMemberRoleGroup {
     my $self = shift;
     my $class = $self->RoleClass;
     return unless $class;
-    return $class->Role($self->Type)->{Single};
+    return $class->Role($self->Name)->{Single};
 }
 
 sub SingleMemberRoleGroupColumn {
@@ -749,7 +765,7 @@ sub SingleMemberRoleGroupColumn {
     my ($class) = $self->Domain =~ /^(.+)-Role$/;
     return unless $class;
 
-    my $role = $class->Role($self->Type);
+    my $role = $class->Role($self->Name);
     return unless $role->{Class} eq $class;
     return $role->{Column};
 }
@@ -763,6 +779,33 @@ sub RoleGroupObject {
     return $obj;
 }
 
+sub Type {
+    my $self = shift;
+    RT->Deprecated( Instead => 'Name', Remove => '4.4' );
+    return $self->_Value('Type', @_);
+}
+
+sub SetType {
+    my $self = shift;
+    RT->Deprecated( Instead => 'Name', Remove => '4.4' );
+    return $self->SetName(@_);
+}
+
+sub SetName {
+    my $self = shift;
+    my $value = shift;
+
+    my ($status, $msg) = $self->_Set( Field => 'Name', Value => $value );
+    return ($status, $msg) unless $status;
+
+    {
+        my ($status, $msg) = $self->__Set( Field => 'Type', Value => $value );
+        RT->Logger->error("Couldn't set Type: $msg") unless $status;
+    }
+
+    return ($status, $msg);
+}
+
 =head2 Delete
 
 Delete this object
@@ -1142,13 +1185,13 @@ sub _AddMember {
                 Type     => 'SetWatcher',
                 OldValue => $old_member_id,
                 NewValue => $new_member_obj->Id,
-                Field    => $self->Type,
+                Field    => $self->Name,
             );
         } else {
             $obj->_NewTransaction(
                 Type     => 'AddWatcher', # use "watcher" for history's sake
                 NewValue => $new_member_obj->Id,
-                Field    => $self->Type,
+                Field    => $self->Name,
             );
         }
     }
@@ -1311,7 +1354,7 @@ sub _DeleteMember {
     if ($self->RoleClass) {
         my %txn = (
             OldValue => $old_member,
-            Field    => $self->Type,
+            Field    => $self->Name,
         );
 
         if ($self->SingleMemberRoleGroup) {
@@ -1554,7 +1597,7 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 Returns the current value of Type.
 (In the database, Type is stored as varchar(64).)
 
-
+Deprecated, use Name instead, will be removed in 4.4.
 
 =head2 SetType VALUE
 
@@ -1563,6 +1606,7 @@ Set Type to VALUE.
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 (In the database, Type will be stored as a varchar(64).)
 
+Deprecated, use SetName instead, will be removed in 4.4.
 
 =cut
 
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index a546f17..6f2272f 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -671,10 +671,9 @@ sub InsertInitialData {
 
         $group = RT::Group->new( RT->SystemUser );
         my ( $val, $msg ) = $group->_Create(
-            Type        => $name,
             Domain      => 'SystemInternal',
             Description => 'Pseudogroup for internal use',  # loc
-            Name        => '',
+            Name        => $name,
             Instance    => '',
         );
         return ($val, $msg) unless $val;
@@ -722,7 +721,7 @@ sub InsertInitialData {
 
         $group = RT::Group->new( RT->SystemUser );
         my ( $val, $msg ) = $group->CreateRoleGroup(
-            Type                => $name,
+            Name                => $name,
             Object              => RT->System,
             Description         => 'SystemRolegroup for internal use',  # loc
             InsideTransaction   => 0,
@@ -973,11 +972,11 @@ sub InsertData {
                 } elsif ( $item->{'GroupDomain'} eq 'SystemInternal' ) {
                   $princ->LoadSystemInternalGroup( $item->{'GroupType'} );
                 } elsif ( $item->{'GroupDomain'} eq 'RT::System-Role' ) {
-                  $princ->LoadRoleGroup( Object => RT->System, Type => $item->{'GroupType'} );
+                  $princ->LoadRoleGroup( Object => RT->System, Name => $item->{'GroupType'} );
                 } elsif ( $item->{'GroupDomain'} eq 'RT::Queue-Role' &&
                           $item->{'Queue'} )
                 {
-                  $princ->LoadRoleGroup( Object => $object, Type => $item->{'GroupType'} );
+                  $princ->LoadRoleGroup( Object => $object, Name => $item->{'GroupType'} );
                 } else {
                   $princ->Load( $item->{'GroupId'} );
                 }
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c3d228b..70a5f58 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3423,7 +3423,7 @@ sub GetPrincipalsMap {
             $system->OrderBy( FIELD => 'Type', ORDER => 'ASC' );
             push @map, [
                 'System' => $system,    # loc_left_pair
-                'Type'   => 1,
+                'Name'   => 1,
             ];
         }
         elsif (/Groups/) {
@@ -3452,7 +3452,7 @@ sub GetPrincipalsMap {
                 my $class = $object->RecordClassFromLookupType;
                 if ($class and $class->DOES("RT::Record::Role::Roles")) {
                     $roles->LimitToRolesForObject(RT->System);
-                    $roles->Limit( FIELD => "Type", VALUE => $_ )
+                    $roles->Limit( FIELD => "Name", VALUE => $_ )
                         for $class->Roles;
                 } else {
                     # No roles to show; so show nothing
@@ -3466,7 +3466,7 @@ sub GetPrincipalsMap {
                 $roles->OrderBy( FIELD => 'Type', ORDER => 'ASC' );
                 push @map, [
                     'Roles' => $roles,  # loc_left_pair
-                    'Type'  => 1
+                    'Name'  => 1
                 ];
             }
         }
@@ -3491,7 +3491,7 @@ sub GetPrincipalsMap {
                 FIELD2 => 'GroupId'
             );
             $Users->Limit( ALIAS => $groups, FIELD => 'Domain', VALUE => 'ACLEquivalence' );
-            $Users->Limit( ALIAS => $groups, FIELD => 'Type', VALUE => 'UserEquiv' );
+            $Users->Limit( ALIAS => $groups, FIELD => 'Name', VALUE => 'UserEquiv' );
 
             push @map, [
                 'Users' => $Users,  # loc_left_pair
diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 05a8348..9777019 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -576,7 +576,7 @@ sub _HasRoleRightQuery {
     ;
 
     if ( $args{'Roles'} ) {
-        $query .= "AND (" . join( ' OR ', map "Groups.Type = '$_'", @{ $args{'Roles'} } ) . ")";
+        $query .= "AND (" . join( ' OR ', map "Groups.Name = '$_'", @{ $args{'Roles'} } ) . ")";
     }
 
     my (@object_clauses);
@@ -704,7 +704,7 @@ return that. if it has no type, return group.
 sub _GetPrincipalTypeForACL {
     my $self = shift;
     if ($self->IsRoleGroup) {
-        return $self->Object->Type;
+        return $self->Object->Name;
     } else {
         return $self->PrincipalType;
     }
diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm
index 2d2c8e9..6b27623 100644
--- a/lib/RT/Record/Role/Roles.pm
+++ b/lib/RT/Record/Role/Roles.pm
@@ -293,13 +293,13 @@ L<RT::Group> object on failure.
 
 sub RoleGroup {
     my $self  = shift;
-    my $type  = shift;
+    my $name  = shift;
     my $group = RT::Group->new( $self->CurrentUser );
 
-    if ($self->HasRole($type)) {
+    if ($self->HasRole($name)) {
         $group->LoadRoleGroup(
             Object  => $self,
-            Type    => $type,
+            Name    => $name,
         );
     }
     return $group;
@@ -567,15 +567,15 @@ sub _ResolveRoles {
 sub _CreateRoleGroups {
     my $self = shift;
     my %args = (@_);
-    for my $type ($self->Roles) {
+    for my $name ($self->Roles) {
         my $type_obj = RT::Group->new($self->CurrentUser);
         my ($id, $msg) = $type_obj->CreateRoleGroup(
-            Type    => $type,
+            Name    => $name,
             Object  => $self,
             %args,
         );
         unless ($id) {
-            $RT::Logger->error("Couldn't create a role group of type '$type' for ".ref($self)." ".
+            $RT::Logger->error("Couldn't create a role group of type '$name' for ".ref($self)." ".
                                    $self->id.": ".$msg);
             return(undef);
         }
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index c39fa90..818402b 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -267,7 +267,7 @@ sub _FieldToFunction {
         my $u_alias = $self->{"_sql_report_watcher_users_alias_$type"};
         unless ( $u_alias ) {
             my ($g_alias, $gm_alias);
-            ($g_alias, $gm_alias, $u_alias) = $self->_WatcherJoin( Type => $type );
+            ($g_alias, $gm_alias, $u_alias) = $self->_WatcherJoin( Name => $type );
             $self->{"_sql_report_watcher_users_alias_$type"} = $u_alias;
         }
         @args{qw(ALIAS FIELD)} = ($u_alias, $column);
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index ff683f9..eff67d1 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -254,6 +254,12 @@ injection attacks when we pass through user specified values.
 
 =cut
 
+my %deprecated = (
+    groups => {
+        type => 'Name',
+    },
+);
+
 sub Limit {
     my $self = shift;
     my %ARGS = (
@@ -287,6 +293,20 @@ sub Limit {
             VALUE    => '0',
         );
     }
+
+    my $table;
+    ($table) = $ARGS{'ALIAS'} && $ARGS{'ALIAS'} ne 'main'
+        ? ($ARGS{'ALIAS'} =~ /^(.*)_\d+$/)
+        : $self->Table
+    ;
+
+    if ( $table and my $instead = $deprecated{ lc $table }{ lc $ARGS{'FIELD'} } ) {
+        RT->Deprecated(
+            Message => "$table.$ARGS{'FIELD'} column is deprecated",
+            Instead => $instead, Remove => '4.4'
+        );
+    }
+
     return $self->SUPER::Limit( %ARGS );
 }
 
diff --git a/lib/RT/SearchBuilder/Role/Roles.pm b/lib/RT/SearchBuilder/Role/Roles.pm
index 8031b82..d06526a 100644
--- a/lib/RT/SearchBuilder/Role/Roles.pm
+++ b/lib/RT/SearchBuilder/Role/Roles.pm
@@ -97,12 +97,18 @@ sub _RoleGroupClass {
 
 sub _RoleGroupsJoin {
     my $self = shift;
-    my %args = (New => 0, Class => '', Type => '', @_);
+    my %args = (New => 0, Class => '', Name => '', @_);
 
     $args{'Class'} ||= $self->_RoleGroupClass;
 
-    return $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $args{'Type'} }
-        if $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $args{'Type'} }
+    my $name = $args{'Name'};
+    if ( exists $args{'Type'} ) {
+        RT->Deprecated( Arguments => 'Type', Instead => 'Name', Remove => '4.4' );
+        $name = $args{'Type'};
+    }
+
+    return $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $name }
+        if $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $name }
            && !$args{'New'};
 
     # If we're looking at a role group on a class that "contains" this record
@@ -129,11 +135,11 @@ sub _RoleGroupsJoin {
     $self->Limit(
         LEFTJOIN        => $groups,
         ALIAS           => $groups,
-        FIELD           => 'Type',
-        VALUE           => $args{'Type'},
-    ) if $args{'Type'};
+        FIELD           => 'Name',
+        VALUE           => $name,
+    ) if $name;
 
-    $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $args{'Type'} } = $groups
+    $self->{'_sql_role_group_aliases'}{ $args{'Class'} .'-'. $name } = $groups
         unless $args{'New'};
 
     return $groups;
@@ -252,7 +258,7 @@ sub RoleLimit {
 
     $args{FIELD} ||= 'EmailAddress';
 
-    my $groups = $self->_RoleGroupsJoin( Type => $type, Class => $class, New => !$type );
+    my $groups = $self->_RoleGroupsJoin( Name => $type, Class => $class, New => !$type );
 
     $self->_OpenParen( $args{SUBCLAUSE} ) if $args{SUBCLAUSE};
     if ( $args{OPERATOR} =~ /^IS(?: NOT)?$/i ) {
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index 9495ff5..ab34537 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -87,7 +87,7 @@ sub __DependsOn
     my $group = $self->GroupObj->Object;
     # XXX: If we delete member of the ticket owner role group then we should also
     # fix ticket object, but only if we don't plan to delete group itself!
-    unless( ($group->Type || '') eq 'Owner' &&
+    unless( ($group->Name || '') eq 'Owner' &&
         ($group->Domain || '') eq 'RT::Ticket-Role' ) {
         return $self->SUPER::__DependsOn( %args );
     }
@@ -106,7 +106,7 @@ sub __DependsOn
                 my %args = (@_);
                 my $group = $args{'TargetObject'};
                 return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
-                return unless ($group->Type || '') eq 'Owner';
+                return unless ($group->Name || '') eq 'Owner';
                 return unless ($group->Domain || '') eq 'RT::Ticket-Role';
 
                 return if $group->MembersObj->Count > 1;
diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index 7bbca13..e6e3dff 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -137,7 +137,7 @@ sub AvailableRights {
 
     # Only return rights on classes which support the role asked for
     if ($principal and $principal->IsRoleGroup) {
-        my $role = $principal->Object->Type;
+        my $role = $principal->Object->Name;
         @types   = grep { $_->DOES('RT::Record::Role::Roles') and $_->HasRole($role) } @types;
         %rights  = ();
     }
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 97ab94a..4496d05 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -919,7 +919,7 @@ sub store_rights {
     my @res;
     while ( my $ace = $acl->Next ) {
         my $obj = $ace->PrincipalObj->Object;
-        if ( $obj->isa('RT::Group') && $obj->Type eq 'UserEquiv' && $obj->Instance == RT->Nobody->id ) {
+        if ( $obj->isa('RT::Group') && $obj->Domain eq 'ACLEquivalence' && $obj->Instance == RT->Nobody->id ) {
             next;
         }
 
@@ -952,7 +952,7 @@ sub set_rights {
     $acl->Limit( FIELD => 'RightName', OPERATOR => '!=', VALUE => 'SuperUser' );
     while ( my $ace = $acl->Next ) {
         my $obj = $ace->PrincipalObj->Object;
-        if ( $obj->isa('RT::Group') && $obj->Type eq 'UserEquiv' && $obj->Instance == RT->Nobody->id ) {
+        if ( $obj->isa('RT::Group') && $obj->Domain eq 'ACLEquivalence' && $obj->Instance == RT->Nobody->id ) {
             next;
         }
         $ace->Delete;
@@ -976,7 +976,7 @@ sub add_rights {
                 $principal = RT::Group->new( RT->SystemUser );
                 $principal->LoadRoleGroup(
                     Object  => ($e->{'Object'} || RT->System),
-                    Type    => $type
+                    Name    => $type
                 );
             }
             die "Principal is not an object nor the name of a system or role group"
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 6437d78..23bb062 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1674,7 +1674,7 @@ sub OrderByCols {
             my $users = $self->{_sql_u_watchers_alias_for_sort}{ $cache_key };
             unless ( $users ) {
                 $self->{_sql_u_watchers_alias_for_sort}{ $cache_key }
-                    = $users = ( $self->_WatcherJoin( Type => $meta->[1], Class => "RT::" . ($meta->[2] || 'Ticket') ) )[2];
+                    = $users = ( $self->_WatcherJoin( Name => $meta->[1], Class => "RT::" . ($meta->[2] || 'Ticket') ) )[2];
             }
             push @res, { %$row, ALIAS => $users, FIELD => $subkey };
        } elsif ( defined $meta->[0] && $meta->[0] eq 'CUSTOMFIELD' ) {
@@ -2938,7 +2938,7 @@ sub CurrentUserCanSee {
         my $groups = RT::Groups->new( RT->SystemUser );
         $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
         foreach ( @tmp ) {
-            $groups->Limit( FIELD => 'Type', VALUE => $_ );
+            $groups->Limit( FIELD => 'Name', VALUE => $_ );
         }
         my $principal_alias = $groups->Join(
             ALIAS1 => 'main',
@@ -3041,7 +3041,7 @@ sub CurrentUserCanSee {
                 $self->Limit(
                     SUBCLAUSE       => 'ACL',
                     ALIAS           => $role_group_alias,
-                    FIELD           => 'Type',
+                    FIELD           => 'Name',
                     VALUE           => $role,
                     ENTRYAGGREGATOR => 'AND',
                 );
diff --git a/share/html/Elements/ShowMemberships b/share/html/Elements/ShowMemberships
index 0dbe67c..1985302 100644
--- a/share/html/Elements/ShowMemberships
+++ b/share/html/Elements/ShowMemberships
@@ -52,7 +52,7 @@
 %    if ($Group->Domain eq 'UserDefined') {
 <li><a href="<%RT->Config->Get('WebPath')%>/Admin/Groups/Modify.html?id=<% $Group->Id %>"><% $Group->Name %></a></li>
 %    } elsif ($Group->Domain eq 'SystemInternal') {
-<li><em><% loc($Group->Type) %></em></li>
+<li><em><% loc($Group->Name) %></em></li>
 %    }
 % }
 </ul>
diff --git a/share/html/Ticket/Elements/EditWatchers b/share/html/Ticket/Elements/EditWatchers
index 3bc6cd7..265f5e6 100644
--- a/share/html/Ticket/Elements/EditWatchers
+++ b/share/html/Ticket/Elements/EditWatchers
@@ -55,7 +55,7 @@
 % while ( my $watcher = $Members->Next ) {
 % my $member = $watcher->MemberObj->Object;
 <li>
-<input type="checkbox" class="checkbox" name="Ticket-DeleteWatcher-Type-<% $Watchers->Type %>-Principal-<% $watcher->MemberId %>" value="1" unchecked />
+<input type="checkbox" class="checkbox" name="Ticket-DeleteWatcher-Type-<% $Watchers->Name %>-Principal-<% $watcher->MemberId %>" value="1" unchecked />
 % if ( $member->isa( 'RT::User' ) ) { 
 % if ( $session{CurrentUser}->HasRight( Right => 'AdminUsers', Object => $RT::System ) &&
 %      $session{CurrentUser}->HasRight( Right => 'ShowConfigTab', Object =>$RT::System ) ) {
diff --git a/t/api/system-available-rights.t b/t/api/system-available-rights.t
index 9c374d6..d7b6f5e 100644
--- a/t/api/system-available-rights.t
+++ b/t/api/system-available-rights.t
@@ -12,7 +12,7 @@ local $SIG{__WARN__} = sub {
 my $requestor = RT::Group->new( RT->SystemUser );
 $requestor->LoadRoleGroup(
     Object  => RT->System,
-    Type    => "Requestor",
+    Name    => "Requestor",
 );
 ok $requestor->id, "Loaded global requestor role group";
 

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


More information about the Rt-commit mailing list