From: tjhunt Date: Wed, 12 Nov 2008 08:28:52 +0000 (+0000) Subject: Reproduce MDL-17210 in this code, until it is fixed. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c04d79503e5f2b146babf97ec84e20c0bd73c2b4;p=moodle.git Reproduce MDL-17210 in this code, until it is fixed. --- diff --git a/admin/roles/explainhascapabiltiy.php b/admin/roles/explainhascapabiltiy.php index 12280173f2..5dfba3f55d 100644 --- a/admin/roles/explainhascapabiltiy.php +++ b/admin/roles/explainhascapabiltiy.php @@ -91,6 +91,7 @@ foreach ($contexts as $con) { } foreach ($contexts as $ocon) { $summedpermission = 0; + $gotsomething = false; foreach ($ras as $roleid) { if (isset($accessdata['rdef'][$ocon->path . ':' . $roleid][$capability])) { $perm = $accessdata['rdef'][$ocon->path . ':' . $roleid][$capability]; @@ -103,12 +104,19 @@ foreach ($contexts as $con) { $decisiveoverridecon = 0; break 3; } + if ($perm) { + $gotsomething = true; + } $summedpermission += $perm; } if ($summedpermission) { $decisiveassigncon = $con->id; $decisiveoverridecon = $ocon->id; break 2; + } else if ($gotsomething) { + // This else clause makes sure this page matches the actual behaviour of + // has_capability, which I believe is buggy. See MDL-17210. + break; } } }