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,8 +56,11 @@ function cleanupArticle( Revision $rev, $regexes, $match ) {
//------------------------------------------------------------------------------
$username = 'Spam cleanup script';
$wgUser = User::newFromName( $username );
if ( $wgUser->idForName() == 0 ) {
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() ) {
@ -65,6 +68,7 @@ if ( $wgUser->idForName() == 0 ) {
$dbw->update( 'user', array( 'user_password' => 'nologin' ),
array( 'user_name' => $username ), $username );
}
}
}
if ( isset( $options['n'] ) ) {