mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-11-24 07:04:04 +00:00
Use User::newSystemUser when available
Change-Id: I0be561ff0a28a728451224239e20f243543c311d
This commit is contained in:
parent
303ba31639
commit
6ee605a088
|
@ -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'] ) ) {
|
||||
|
|
Loading…
Reference in a new issue