public function __construct() {
parent::__construct();
- $this->mDescription = "Cleanup all spam from a given hostname";
+ $this->addDescription( 'Cleanup all spam from a given hostname' );
$this->addOption( 'all', 'Check all wikis in $wgLocalDatabases' );
$this->addOption( 'delete', 'Delete pages containing only spam instead of blanking them' );
$this->addArg(
$this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" );
$found = false;
foreach ( $wgLocalDatabases as $wikiID ) {
- $dbr = $this->getDB( DB_SLAVE, array(), $wikiID );
+ $dbr = $this->getDB( DB_REPLICA, [], $wikiID );
$count = $dbr->selectField( 'externallinks', 'COUNT(*)',
- array( 'el_index' . $dbr->buildLike( $like ) ), __METHOD__ );
+ [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ );
if ( $count ) {
$found = true;
$cmd = wfShellWikiCmd( "$IP/maintenance/cleanupSpam.php",
- array( '--wiki', $wikiID, $spec ) );
+ [ '--wiki', $wikiID, $spec ] );
passthru( "$cmd | sed 's/^/$wikiID: /'" );
}
}
} else {
// Clean up spam on this wiki
- $dbr = $this->getDB( DB_SLAVE );
- $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ),
- array( 'el_index' . $dbr->buildLike( $like ) ), __METHOD__ );
+ $dbr = $this->getDB( DB_REPLICA );
+ $res = $dbr->select( 'externallinks', [ 'DISTINCT el_from' ],
+ [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ );
$count = $dbr->numRows( $res );
$this->output( "Found $count articles containing $spec\n" );
foreach ( $res as $row ) {