-
Bug
-
Resolution: Fixed
-
Minor
-
3.2.5, 3.3.2, 3.5.3, 3.6.1
-
MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-60518-master -
- Run PHPUnit on lib/tests/user_test.php
Code may speak better than words, so here it is
public static function is_real_user($userid, $checkdb = false) {
|
global $DB;
|
|
if ($userid < 0) {
|
return false;
|
}
|
if ($checkdb) {
|
return $DB->record_exists('user', array('id' => $userid));
|
} else {
|
return true;
|
}
|
}
|
For $userid = 0, the method will return True if $checkdb is False, else it will return False.
I advocate that it should return False for a userid of 0 as it is not present in the database. This was discovered when I evaluated the possibility of using this method for checking whether a user was meant to be in the database without performing any DB query.