additional checks before foreach() loop

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47582 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-01-03 00:49:28 +00:00
parent 3a47be1430
commit b5aaa9b1e2

View File

@ -425,7 +425,7 @@ class Permission extends DataObject {
} }
$allCodes['ADMIN'] = 'Full administrative rights'; $allCodes['ADMIN'] = 'Full administrative rights';
foreach($classes as $class) { if($classes) foreach($classes as $class) {
$SNG = singleton($class); $SNG = singleton($class);
$someCodes = $SNG->providePermissions(); $someCodes = $SNG->providePermissions();
if($someCodes) foreach($someCodes as $k => $v) { if($someCodes) foreach($someCodes as $k => $v) {
@ -435,7 +435,7 @@ class Permission extends DataObject {
$otherPerms = DB::query("SELECT DISTINCT Code From Permission") $otherPerms = DB::query("SELECT DISTINCT Code From Permission")
->column(); ->column();
foreach($otherPerms as $otherPerm) { if($otherPerms) foreach($otherPerms as $otherPerm) {
if(!array_key_exists($otherPerm, $allCodes)) if(!array_key_exists($otherPerm, $allCodes))
$allCodes[$otherPerm] = $otherPerm; $allCodes[$otherPerm] = $otherPerm;
} }