[Rt-commit] rt branch, 4.2/deprecate-type-column-in-groups, created. rt-4.1.8-480-g8a3a4bd
Alex Vandiver
alexmv at bestpractical.com
Fri May 24 16:02:13 EDT 2013
The branch, 4.2/deprecate-type-column-in-groups has been created
at 8a3a4bd503510e7a953ce2a9cd9a645d0bbd5a48 (commit)
- Log -----------------------------------------------------------------
commit ac284f23d226d63e8cb861b3ac9a7024c7276afb
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 09bf572..2485bef 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -764,7 +764,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
@@ -774,15 +773,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 71fcde3253ed49778470cec793ef3658e6226085
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.13/schema.Oracle b/etc/upgrade/4.1.13/schema.Oracle
new file mode 100644
index 0000000..96869c6
--- /dev/null
+++ b/etc/upgrade/4.1.13/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.13/schema.Pg b/etc/upgrade/4.1.13/schema.Pg
new file mode 100644
index 0000000..96869c6
--- /dev/null
+++ b/etc/upgrade/4.1.13/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.13/schema.SQLite b/etc/upgrade/4.1.13/schema.SQLite
new file mode 100644
index 0000000..9ea6a91
--- /dev/null
+++ b/etc/upgrade/4.1.13/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.13/schema.mysql b/etc/upgrade/4.1.13/schema.mysql
new file mode 100644
index 0000000..a429007
--- /dev/null
+++ b/etc/upgrade/4.1.13/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 50076ab..aceb23a 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -677,10 +677,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;
@@ -728,7 +727,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,
@@ -979,11 +978,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 ad9c247..e82d885 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3535,7 +3535,7 @@ sub GetPrincipalsMap {
$system->OrderBy( FIELD => 'Type', ORDER => 'ASC' );
push @map, [
'System' => $system, # loc_left_pair
- 'Type' => 1,
+ 'Name' => 1,
];
}
elsif (/Groups/) {
@@ -3564,7 +3564,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
@@ -3578,7 +3578,7 @@ sub GetPrincipalsMap {
$roles->OrderBy( FIELD => 'Type', ORDER => 'ASC' );
push @map, [
'Roles' => $roles, # loc_left_pair
- 'Type' => 1
+ 'Name' => 1
];
}
}
@@ -3603,7 +3603,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 afd79e2..43e7fba 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 2485bef..87e2edd 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -747,6 +747,12 @@ injection attacks when we pass through user specified values.
=cut
+my %deprecated = (
+ groups => {
+ type => 'Name',
+ },
+);
+
sub Limit {
my $self = shift;
my %ARGS = (
@@ -780,6 +786,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 7167b13..b1a3294 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;
@@ -256,7 +262,7 @@ sub RoleLimit {
if ( $args{'BUNDLE'} ) {
($groups, $group_members, $users) = @{ $args{'BUNDLE'} };
} else {
- $groups = $self->_RoleGroupsJoin( Type => $type, Class => $class, New => !$type );
+ $groups = $self->_RoleGroupsJoin( Name => $type, Class => $class, New => !$type );
}
$self->_OpenParen( $args{SUBCLAUSE} ) if $args{SUBCLAUSE};
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 7b0a4cb..e8143fa 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -139,7 +139,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 a4faa55..afeb9db 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -931,7 +931,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;
}
@@ -964,7 +964,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;
@@ -988,7 +988,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 8b718ff..d23e8d3 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1233,7 +1233,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' ) {
@@ -2459,7 +2459,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',
@@ -2562,7 +2562,7 @@ sub CurrentUserCanSee {
$self->Limit(
SUBCLAUSE => 'ACL',
ALIAS => $role_group_alias,
- FIELD => 'Type',
+ FIELD => 'Name',
VALUE => $role,
ENTRYAGGREGATOR => 'AND',
);
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index cf27993..fc17854 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -440,7 +440,7 @@ sub WhoHaveRoleRight
VALUE => RT->SystemUser->id
);
- $self->_AddSubClause( "WhichRole", "(". join( ' OR ', map "$groups.Type = '$_'", @roles ) .")" );
+ $self->_AddSubClause( "WhichRole", "(". join( ' OR ', map "$groups.Name = '$_'", @roles ) .")" );
my @groups_clauses = $self->_RoleClauses( $groups, @objects );
$self->_AddSubClause( "WhichObject", "(". join( ' OR ', @groups_clauses ) .")" )
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";
commit 9e34efe08f4da0021c7f2d293a30a90bf8e5786f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri May 17 18:46:13 2013 +0400
Move backcompat files to code, for greater flexibility
The existing back-compat format was limited to one style of
code-vs-database incompatibility. Move to code which is wrapped around
every upgrade in its series, to allow for arbitrary other types of
alterations.
diff --git a/etc/upgrade/3.9.5/backcompat b/etc/upgrade/3.9.5/backcompat
index f7b66c9..ca0b289 100644
--- a/etc/upgrade/3.9.5/backcompat
+++ b/etc/upgrade/3.9.5/backcompat
@@ -1 +1,15 @@
-RT::ACE LastUpdated LastUpdatedBy Creator Created
+my ($upgrade) = @_;
+
+my %removed;
+my @fields = qw/LastUpdated LastUpdatedBy Creator Created/;
+
+RT::ACE->_BuildTableAttributes;
+$RT::Logger->debug("Temporarily removing @fields from RT::ACE");
+$removed{$_} = delete $RT::Record::_TABLE_ATTR->{"RT::ACE"}{$_}
+ for @fields;
+
+$upgrade->();
+
+# Put back the fields we chopped off
+$RT::Record::_TABLE_ATTR->{"RT::ACE"}{$_} = $removed{$_}
+ for @fields;
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 910bfe9..11a1691 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -268,30 +268,23 @@ sub action_insert {
$file = $RT::EtcPath . "/initialdata" if $init && !$file;
$file ||= $args{'datadir'}."/content";
- # Slurp in backcompat
- my %removed;
- my @back = @{$args{backcompat} || []};
- if (@back) {
- my @lines = do {local @ARGV = @back; <>};
- for (@lines) {
- s/\#.*//;
- next unless /\S/;
- my ($class, @fields) = split;
- $class->_BuildTableAttributes;
- $RT::Logger->debug("Temporarily removing @fields from $class");
- $removed{$class}{$_} = delete $RT::Record::_TABLE_ATTR->{$class}{$_}
- for @fields;
- }
- }
+ my @ret;
- my @ret = $RT::Handle->InsertData( $file, $root_password );
+ my $upgrade = sub { @ret = $RT::Handle->InsertData( $file, $root_password ) };
- # Put back the fields we chopped off
- for my $class (keys %removed) {
- $RT::Record::_TABLE_ATTR->{$class}{$_} = $removed{$class}{$_}
- for keys %{$removed{$class}};
+ for my $file (@{$args{backcompat} || []}) {
+ my $lines = do {local $/; local @ARGV = ($file); <>};
+ my $sub = eval "sub {\n$lines\n}";
+ unless ($sub) {
+ warn "Failed to load backcompat $file: $@";
+ next;
+ }
+ my $current = $upgrade;
+ $upgrade = sub { $sub->($current) };
}
+ $upgrade->();
+
my $content;
open my $handle, '<', $file or warn "Unable to open $file: $!";
if ($handle) {
commit 8a3a4bd503510e7a953ce2a9cd9a645d0bbd5a48
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri May 17 18:49:13 2013 +0400
we have to set Name = Type earlier for upgrade
If we don't new code may fail during upgrade
diff --git a/etc/upgrade/4.1.10/backcompat b/etc/upgrade/4.1.10/backcompat
new file mode 100644
index 0000000..b4e69a3
--- /dev/null
+++ b/etc/upgrade/4.1.10/backcompat
@@ -0,0 +1,31 @@
+my $upgrade = shift;
+
+my $groups = RT::Groups->new( RT->SystemUser );
+$groups->Limit(
+ FIELD => 'Name', OPERATOR => '!=', VALUE => 'main.Type', QUOTEVALUE => 0
+);
+$groups->Limit(
+ FIELD => 'Domain',
+ VALUE => 'SystemInternal',
+ CASESENSITIVE => 0,
+);
+$groups->RowsPerPage(1);
+if ( $groups->Next ) {
+ my $dbh = $RT::Handle->dbh;
+ my $db_type = RT->Config->Get('DatabaseType');
+ if ( $db_type eq 'Oracle' || $db_type eq 'Pg' ) {
+ $dbh->do(
+ "UPDATE Groups SET Name = Type
+ WHERE LOWER(Domain) IN ('aclequivalence', 'systeminternal')
+ OR LOWER(Domain) LIKE '%-role'"
+ );
+ } else {
+ $dbh->do(
+ "UPDATE Groups SET Name = Type
+ WHERE Domain IN ('ACLEquivalence', 'SystemInternal')
+ OR Domain LIKE '%-Role'"
+ );
+ }
+}
+
+$upgrade->();
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list