mirror of
https://github.com/moodle/moodle.git
synced 2025-03-20 07:30:01 +01:00
MDL-65926 moodlelib: Convert username to lowercase prior to SQL query
Within a very large project, it was found that searching for a user with their username in the user table using a case insensitive search was inefficient. Instead it is proposed that the username input is made to be lowercase prior to executing a database query as the username for each user in the database must be lowercase. This allows for a case sensitive query to find the user data. Essentially we are moving a case insensitive search for a user from SQL into PHP to increase performance.
This commit is contained in:
parent
fac49f8f72
commit
907be50c42
@ -4826,7 +4826,12 @@ function get_complete_user_data($field, $value, $mnethostid = null, $throwexcept
|
||||
$field = core_text::strtolower($field);
|
||||
|
||||
// List of case insensitive fields.
|
||||
$caseinsensitivefields = ['username', 'email'];
|
||||
$caseinsensitivefields = ['email'];
|
||||
|
||||
// Username input is forced to lowercase and should be case sensitive.
|
||||
if ($field == 'username') {
|
||||
$value = core_text::strtolower($value);
|
||||
}
|
||||
|
||||
// Build the WHERE clause for an SQL query.
|
||||
$params = array('fieldval' => $value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user