[Rt-commit] rt branch, 4.2/record-role-resolution-args, created. rt-4.2.3-56-g2f06aab
Wallace Reis
wreis at bestpractical.com
Mon Mar 24 14:39:23 EDT 2014
The branch, 4.2/record-role-resolution-args has been created
at 2f06aab252887c6721f03d83024eb63e1db188ad (commit)
- Log -----------------------------------------------------------------
commit 2f06aab252887c6721f03d83024eb63e1db188ad
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Aug 7 15:56:40 2013 -0700
Bulletproofing of role resolution for Create args
Single-member roles will use the first element on an array if an array
is given and an object is checked for before calling ->id blindly on a
value that may be undef. These changes make it easier for programmatic
generation of Create args and has the new REST API as motivation.
diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm
index c1e03fd..c67c58a 100644
--- a/lib/RT/Record/Role/Roles.pm
+++ b/lib/RT/Record/Role/Roles.pm
@@ -519,6 +519,7 @@ sub _ResolveRoles {
if ($self->_ROLES->{$role}{Single}) {
# Default to nobody if unspecified
my $value = $args{$role} || RT->Nobody;
+ $value = $value->[0] if ref $value eq 'ARRAY';
if (Scalar::Util::blessed($value) and $value->isa("RT::User")) {
# Accept a user; it may not be loaded, which we catch below
$roles->{$role} = $value->PrincipalObj;
@@ -530,7 +531,7 @@ sub _ResolveRoles {
$user->LoadByEmail( $value ) unless $user->id;
$roles->{$role} = $user->PrincipalObj;
}
- unless ($roles->{$role} and $roles->{$role}->id) {
+ unless (Scalar::Util::blessed($roles->{$role}) and $roles->{$role}->id) {
push @errors, $self->loc("Invalid value for [_1]",$self->loc($role));
$roles->{$role} = RT->Nobody->PrincipalObj;
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list