Performance issue with default username when creating new users
The following code turns out to be really slow if a lot of users without usernames are created:
\QUI\Users\Manager->createChild()
<?php
// ...
$newUserLocale = QUI::getLocale()->get('quiqqer/quiqqer', 'user.create.new.username');
$newName = $newUserLocale;
$i = 0;
while ($this->usernameExists($newName)) {
$newName = $newUserLocale . ' (' . $i . ')';
$i++;
}
// ...
Depending on how many users with the fallback username (e.g. "New User (X)") already exist, the while
loop will make the system slower and slower over time.
Suggestion by @mor : Use the current timestamp instead of an increasing number for the default username.