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
20
cleanup.php
20
cleanup.php
|
@ -56,14 +56,18 @@ function cleanupArticle( Revision $rev, $regexes, $match ) {
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
$username = 'Spam cleanup script';
|
$username = 'Spam cleanup script';
|
||||||
$wgUser = User::newFromName( $username );
|
if ( method_exists( 'User', 'newSystemUser' ) ) {
|
||||||
if ( $wgUser->idForName() == 0 ) {
|
$wgUser = User::newSystemUser( $username, array( 'steal' => true ) );
|
||||||
// Create the user
|
} else {
|
||||||
$status = $wgUser->addToDatabase();
|
$wgUser = User::newFromName( $username );
|
||||||
if ( $status === null || $status->isOK() ) {
|
if ( $wgUser->idForName() == 0 ) {
|
||||||
$dbw = wfGetDB( DB_MASTER );
|
// Create the user
|
||||||
$dbw->update( 'user', array( 'user_password' => 'nologin' ),
|
$status = $wgUser->addToDatabase();
|
||||||
array( 'user_name' => $username ), $username );
|
if ( $status === null || $status->isOK() ) {
|
||||||
|
$dbw = wfGetDB( DB_MASTER );
|
||||||
|
$dbw->update( 'user', array( 'user_password' => 'nologin' ),
|
||||||
|
array( 'user_name' => $username ), $username );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue