Use User::newSystemUser when available

Change-Id: I0be561ff0a28a728451224239e20f243543c311d
This commit is contained in:
Brad Jorsch 2016-05-13 14:35:41 -04:00
parent 303ba31639
commit 6ee605a088

View file

@ -56,14 +56,18 @@ function cleanupArticle( Revision $rev, $regexes, $match ) {
//------------------------------------------------------------------------------
$username = 'Spam cleanup script';
$wgUser = User::newFromName( $username );
if ( $wgUser->idForName() == 0 ) {
// Create the user
$status = $wgUser->addToDatabase();
if ( $status === null || $status->isOK() ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'user', array( 'user_password' => 'nologin' ),
array( 'user_name' => $username ), $username );
if ( method_exists( 'User', 'newSystemUser' ) ) {
$wgUser = User::newSystemUser( $username, array( 'steal' => true ) );
} else {
$wgUser = User::newFromName( $username );
if ( $wgUser->idForName() == 0 ) {
// Create the user
$status = $wgUser->addToDatabase();
if ( $status === null || $status->isOK() ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'user', array( 'user_password' => 'nologin' ),
array( 'user_name' => $username ), $username );
}
}
}