Merge "User: Use "Unknown user" for bad user id"

This commit is contained in:
jenkins-bot 2020-09-24 22:47:47 +00:00 committed by Gerrit Code Review
commit 52bc746afa
3 changed files with 11 additions and 2 deletions

View file

@ -5235,7 +5235,7 @@ $wgReservedUsernames = [
'Maintenance script', // Maintenance scripts which perform editing, image import script
'Template namespace initialisation script', // Used in 1.2->1.3 upgrade
'ScriptImporter', // Default user name used by maintenance/importSiteScripts.php
'Unknown user', // Used in WikiImporter and RevisionStore for revisions with no author
'Unknown user', // Used in WikiImporter & RevisionStore for revisions with no author and in User for invalid user id
'msg:double-redirect-fixer', // Automatic double redirect fix
'msg:usermessage-editor', // Default user for leaving user messages
'msg:proxyblocker', // For $wgProxyList and Special:Blockme (removed in 1.22)

View file

@ -1274,7 +1274,7 @@ class User implements IDBAccessObject, UserIdentity {
// Invalid user_id
$this->mId = 0;
$this->loadDefaults();
$this->loadDefaults( 'Unknown user' );
return false;
}

View file

@ -2645,4 +2645,13 @@ class UserTest extends MediaWikiIntegrationTestCase {
]
] );
}
/**
* @covers User::loadFromDatabase
* @covers User::loadDefaults
*/
public function testBadUserID() {
$user = User::newFromId( 999999999 );
$this->assertSame( 'Unknown user', $user->getName() );
}
}