Recently, I ran the following on enwiki:
$user = User::newFromId( 84276 );
$user->setOption( 'echo-subscriptions-email-edit-user-talk', 0 );
$user->saveSettings();
This resulted in the following database error:
Error: 1062 Duplicate entry 'Evzob' for key 'user_name'
The reason for this is that user 84276 previously had the username Evzob, but changed their username to something else about 2 months ago. In the meantime, someone else created a new account named Evzob. If you query MediaWiki for the username of user 84276, it still reports it as Evzob two months after it was changed:
$user = User::newFromId( 84276 );
print_r( $user->getName() );
Evzob
...but also...
$user = User::newFromId( 18409122 );
print_r( $user->getName() );
Evzob
That's from eval.php on enwiki. If you query the database directly, it gives you the up-to-date usernames. Obviously having MediaWiki think there are 2 different users with the same username (for 2 months) is a problem.
To avoid this we should probably do something like:
$user->clearInstanceCache( true );
from Renameuser_body.php around line 460.
Version: unspecified
Severity: major