mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-35854 fix username generator
This eliminates infinite loop and also fixes potentially invalid email derived from usernames created from unicode first/last name.
This commit is contained in:
parent
2105f57590
commit
fe67134eaa
2 changed files with 9 additions and 2 deletions
|
@ -157,9 +157,11 @@ EOD;
|
|||
}
|
||||
|
||||
if (!isset($record['username'])) {
|
||||
$record['username'] = textlib::strtolower($record['firstname']).textlib::strtolower($record['lastname']);
|
||||
$record['username'] = 'username'.$i;
|
||||
$j = 2;
|
||||
while ($DB->record_exists('user', array('username'=>$record['username'], 'mnethostid'=>$record['mnethostid']))) {
|
||||
$record['username'] = $record['username'].'_'.$i;
|
||||
$record['username'] = 'username'.$i.'_'.$j;
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue