X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupSpam.php;h=e1ea247377a7ddfbb1ff8b8e234c5206020d908a;hb=742c4988b9c10af39909dceaec3997dcc8745b48;hp=24ca86d60f2c6e68c92314462f76e0678508d638;hpb=2f1e5a8d22d7c005e72f8bdb732e6d7076ac3344;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 24ca86d60f..e1ea247377 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -52,15 +52,15 @@ class CleanupSpam extends Maintenance { // Hack: Grant bot rights so we don't flood RecentChanges $wgUser->addGroup( 'bot' ); - $spec = $this->getArg(); + $spec = $this->getArg( 0 ); - $likes = []; + $protConds = []; foreach ( [ 'http://', 'https://' ] as $prot ) { - $like = LinkFilter::makeLikeArray( $spec, $prot ); - if ( !$like ) { + $conds = LinkFilter::getQueryConditions( $spec, [ 'protocol' => $prot ] ); + if ( !$conds ) { $this->fatalError( "Not a valid hostname specification: $spec" ); } - $likes[$prot] = $like; + $protConds[$prot] = $conds; } if ( $this->hasOption( 'all' ) ) { @@ -68,14 +68,14 @@ class CleanupSpam extends Maintenance { $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); $found = false; foreach ( $wgLocalDatabases as $wikiID ) { - /** @var $dbr Database */ + /** @var Database $dbr */ $dbr = $this->getDB( DB_REPLICA, [], $wikiID ); - foreach ( $likes as $like ) { + foreach ( $protConds as $conds ) { $count = $dbr->selectField( 'externallinks', 'COUNT(*)', - [ 'el_index' . $dbr->buildLike( $like ) ], + $conds, __METHOD__ ); if ( $count ) { @@ -97,13 +97,13 @@ class CleanupSpam extends Maintenance { // Clean up spam on this wiki $count = 0; - /** @var $dbr Database */ + /** @var Database $dbr */ $dbr = $this->getDB( DB_REPLICA ); - foreach ( $likes as $prot => $like ) { + foreach ( $protConds as $prot => $conds ) { $res = $dbr->select( 'externallinks', [ 'DISTINCT el_from' ], - [ 'el_index' . $dbr->buildLike( $like ) ], + $conds, __METHOD__ ); $count = $dbr->numRows( $res );