[Rt-commit] rt branch, 4.2/deprecate-objectid-column-in-principals, created. rt-4.1.8-481-gf146447
Alex Vandiver
alexmv at bestpractical.com
Fri May 24 16:06:47 EDT 2013
The branch, 4.2/deprecate-objectid-column-in-principals has been created
at f146447d2e5ae2cd273d13ba1703963ae0c93393 (commit)
- Log -----------------------------------------------------------------
commit f146447d2e5ae2cd273d13ba1703963ae0c93393
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Apr 19 16:15:24 2013 +0400
deprecate Principal.ObjectId
ObjectId is always equal to id and we mix usage in many
places and almost don't use ObjectId.
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 69e730f..b7a3648 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -1481,17 +1481,9 @@ The response is cached. PrincipalObj should never ever change.
sub PrincipalObj {
my $self = shift;
- unless ( defined $self->{'PrincipalObj'} &&
- defined $self->{'PrincipalObj'}->ObjectId &&
- ($self->{'PrincipalObj'}->ObjectId == $self->Id) &&
- (defined $self->{'PrincipalObj'}->PrincipalType &&
- $self->{'PrincipalObj'}->PrincipalType eq 'Group')) {
-
- $self->{'PrincipalObj'} = RT::Principal->new($self->CurrentUser);
- $self->{'PrincipalObj'}->LoadByCols('ObjectId' => $self->Id,
- 'PrincipalType' => 'Group') ;
- }
- return($self->{'PrincipalObj'});
+ my $res = RT::Principal->new( $self->CurrentUser );
+ $res->Load( $self->id );
+ return $res;
}
diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 9777019..e87a3cb 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -139,7 +139,7 @@ sub Object {
$RT::Logger->crit("Found a principal (".$self->Id.") that was neither a user nor a group");
return(undef);
}
- $self->{'object'}->Load( $self->ObjectId() );
+ $self->{'object'}->Load( $self->id );
}
return ($self->{'object'});
@@ -735,7 +735,20 @@ sub _ReferenceId {
}
}
+sub ObjectId {
+ my $self = shift;
+ RT->Deprecated( Instead => 'id', Remove => '4.4' );
+ return $self->_Value('ObjectId');
+}
+sub LoadByCols {
+ my $self = shift;
+ my %args = @_;
+ if ( exists $args{'ObjectId'} ) {
+ RT->Deprecated( Arguments => 'ObjectId', Instead => 'id', Remove => '4.4' );
+ }
+ return $self->SUPER::LoadByCols( %args );
+}
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 87e2edd..6397055 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -751,6 +751,7 @@ my %deprecated = (
groups => {
type => 'Name',
},
+ principals => { objectid => 'id' },
);
sub Limit {
diff --git a/t/api/group.t b/t/api/group.t
index 2c1ca73..9ba3257 100644
--- a/t/api/group.t
+++ b/t/api/group.t
@@ -88,7 +88,7 @@ is($group_3->HasMemberRecursively($principal_2), undef, "group 3 has member 2 re
ok(my $u = RT::Group->new(RT->SystemUser));
ok($u->Load(4), "Loaded the first user");
-is($u->PrincipalObj->ObjectId , 4, "user 4 is the fourth principal");
+is($u->PrincipalObj->id , 4, "user 4 is the fourth principal");
is($u->PrincipalObj->PrincipalType , 'Group' , "Principal 4 is a group");
diff --git a/t/api/user.t b/t/api/user.t
index 316bcc1..94494f1 100644
--- a/t/api/user.t
+++ b/t/api/user.t
@@ -106,7 +106,7 @@ ok($user->Privileged, "User 'root' is privileged again");
ok(my $u = RT::User->new(RT->SystemUser));
ok($u->Load(1), "Loaded the first user");
-is($u->PrincipalObj->ObjectId , 1, "user 1 is the first principal");
+is($u->PrincipalObj->id , 1, "user 1 is the first principal");
is($u->PrincipalObj->PrincipalType, 'User' , "Principal 1 is a user, not a group");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list