mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-11-23 22:54:57 +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';
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue