From cedc2f6dd49e8b4cc8cbb6e7b9ee80aba2a0729d Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Fri, 9 Dec 2011 15:07:17 -0400 Subject: [PATCH] Fixed a warning in SecurityClass.inc In SecurityClass.inc it is possible to get the warnings: warning: Invalid argument supplied for foreach() in /var/www/sites/all/modules/fedora_repository/SecurityClass.inc on line 84. warning: Invalid argument supplied for foreach() in /var/www/sites/all/modules/fedora_repository/SecurityClass.inc on line 89. These happen when the XACML policy doesn't contain any roles or users. --- SecurityClass.inc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SecurityClass.inc b/SecurityClass.inc index 1f3df0eb..06b5844a 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -81,11 +81,15 @@ class SecurityClass { $roles = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="fedoraRole"]/../default:Apply/default:AttributeValue'); $users = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="urn:fedora:names:fedora:2.1:subject:loginId"]/../default:Apply/default:AttributeValue'); - foreach($roles as $role) { - $allowedRoles[] = (string)$role; + if($roles) { + foreach($roles as $role) { + $allowedRoles[] = (string)$role; + } } - foreach($users as $user) { - $allowedUsers[] = (string)$user; + if($users) { + foreach($users as $user) { + $allowedUsers[] = (string)$user; + } } $usersAndRoles['users'] = $allowedUsers;