[Rt-commit] rt branch, 4.2/support-rest-v2, created. rt-4.2.3-56-ge187cfd
Wallace Reis
wreis at bestpractical.com
Fri Mar 21 06:07:58 EDT 2014
The branch, 4.2/support-rest-v2 has been created
at e187cfdf8519770dd58053ddf9d0167c5eaf9791 (commit)
- Log -----------------------------------------------------------------
commit e187cfdf8519770dd58053ddf9d0167c5eaf9791
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.
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