X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupSpam.php;h=3d039fa292f1664e6f421b67ad7fda5d719c4d10;hb=ee3f8a60ef877efe86ef07e0f96060a0930532c6;hp=2f3f01347ca30b085f7fca7a28a64782efa3676d;hpb=e3bd13db0c285f312e31bb1b7271af4628cca80c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 2f3f01347c..3d039fa292 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -47,16 +47,15 @@ class CleanupSpam extends Maintenance { $username = wfMessage( 'spambot_username' )->text(); $wgUser = User::newSystemUser( $username ); if ( !$wgUser ) { - $this->error( "Invalid username specified in 'spambot_username' message: $username", true ); - } - // Create the user if necessary - if ( !$wgUser->getId() ) { - $wgUser->addToDatabase(); + $this->fatalError( "Invalid username specified in 'spambot_username' message: $username" ); } + // Hack: Grant bot rights so we don't flood RecentChanges + $wgUser->addGroup( 'bot' ); + $spec = $this->getArg(); $like = LinkFilter::makeLikeArray( $spec ); if ( !$like ) { - $this->error( "Not a valid hostname specification: $spec", true ); + $this->fatalError( "Not a valid hostname specification: $spec" ); } if ( $this->hasOption( 'all' ) ) { @@ -64,7 +63,7 @@ class CleanupSpam extends Maintenance { $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); $found = false; foreach ( $wgLocalDatabases as $wikiID ) { - $dbr = $this->getDB( DB_SLAVE, [], $wikiID ); + $dbr = $this->getDB( DB_REPLICA, [], $wikiID ); $count = $dbr->selectField( 'externallinks', 'COUNT(*)', [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); @@ -83,7 +82,7 @@ class CleanupSpam extends Maintenance { } else { // Clean up spam on this wiki - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( 'externallinks', [ 'DISTINCT el_from' ], [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); $count = $dbr->numRows( $res ); @@ -131,7 +130,7 @@ class CleanupSpam extends Maintenance { $page->doEditContent( $content, wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(), - EDIT_UPDATE, + EDIT_UPDATE | EDIT_FORCE_BOT, $rev->getId() ); } elseif ( $this->hasOption( 'delete' ) ) { @@ -148,7 +147,8 @@ class CleanupSpam extends Maintenance { $this->output( "blanking\n" ); $page->doEditContent( $content, - wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text() + wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text(), + EDIT_UPDATE | EDIT_FORCE_BOT ); } $this->commitTransaction( $dbw, __METHOD__ );