MDL-64950 core: Handle username in a case-insensitive fashion
This commit is contained in:
+14
-1
@@ -4769,9 +4769,22 @@ function get_complete_user_data($field, $value, $mnethostid = null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change the field to lowercase.
|
||||
$field = core_text::strtolower($field);
|
||||
|
||||
// List of case insensitive fields.
|
||||
$caseinsensitivefields = ['username'];
|
||||
|
||||
// Build the WHERE clause for an SQL query.
|
||||
$params = array('fieldval' => $value);
|
||||
$constraints = "$field = :fieldval AND deleted <> 1";
|
||||
|
||||
// Do a case-insensitive query, if necessary.
|
||||
if (in_array($field, $caseinsensitivefields)) {
|
||||
$fieldselect = $DB->sql_equal($field, ':fieldval', false);
|
||||
} else {
|
||||
$fieldselect = "$field = :fieldval";
|
||||
}
|
||||
$constraints = "$fieldselect AND deleted <> 1";
|
||||
|
||||
// If we are loading user data based on anything other than id,
|
||||
// we must also restrict our search based on mnet host.
|
||||
|
||||
Reference in New Issue
Block a user