mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Put back DEBUG_DEVELOPER sanity check in has_capability, that makes sure the capabiltiy you are asking about actually exists. I know it takes an extra DB query, but it is DEBUG_DEVELOPER only, and it is worth its weight in gold, because otherwise you get really subtle bugs that take forever to diagnose. I know, I have just been banging my head against the wall for an hour.
This commit is contained in:
parent
4282d047c2
commit
cc3d5e10ec
@ -327,6 +327,16 @@ function has_capability($capability, $context, $userid=NULL, $doanything=true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Some sanity checks
|
||||
if (debugging('',DEBUG_DEVELOPER)) {
|
||||
if (!record_exists('capabilities', 'name', $capability)) {
|
||||
debugging('Capability "'.$capability.'" was not found! This should be fixed in code.');
|
||||
}
|
||||
if ($doanything != true and $doanything != false) {
|
||||
debugging('Capability parameter "doanything" is wierd ("'.$doanything.'"). This should be fixed in code.');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($userid)) { // we must accept null, 0, '0', '' etc. in $userid
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user