Prepend x to section ids not starting with [a-z]
[lhc/web/wiklou.git] / maintenance / cleanupSpam.php
index 65d6bc4..eb9bd91 100644 (file)
@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * @ingroup Maintenance
+ */
 
 require_once( 'commandLine.inc' );
 require_once( "$IP/includes/LinkFilter.php" );
@@ -12,12 +16,10 @@ function cleanupArticle( $id, $domain ) {
 
        print $title->getPrefixedDBkey() . " ...";
        $rev = Revision::newFromTitle( $title );
-       $reverted = false;
        $revId = $rev->getId();
        $currentRevId = $revId;
-       $regex = LinkFilter::makeRegex( $domain );
        
-       while ( $rev && preg_match( $regex, $rev->getText() ) ) {
+       while ( $rev && LinkFilter::matchEntry( $rev->getText() , $domain ) ) {
                # Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
                #$rev = $rev->getPrevious();
                $revId = $title->getPreviousRevisionID( $revId );
@@ -32,7 +34,7 @@ function cleanupArticle( $id, $domain ) {
                // This happens e.g. when a link comes from a template rather than the page itself
                print "False match\n";
        } else {
-               $dbw =& wfGetDB( DB_MASTER );
+               $dbw = wfGetDB( DB_MASTER );
                $dbw->immediateBegin();
                if ( !$rev ) {
                        // Didn't find a non-spammy revision, blank the page
@@ -60,7 +62,7 @@ $username = wfMsg( 'spambot_username' );
 $fname = $username;
 $wgUser = User::newFromName( $username );
 // Create the user if necessary
-if ( !$wgUser->getID() ) {
+if ( !$wgUser->getId() ) {
        $wgUser->addToDatabase();
 }
 
@@ -75,11 +77,11 @@ if ( !$like ) {
        exit(1);
 }
 
-$dbr =& wfGetDB( DB_SLAVE );
+$dbr = wfGetDB( DB_SLAVE );
 
-if ( $options['all'] ) {
+if ( isset($options['all']) ) {
        // Clean up spam on all wikis
-       $dbr =& wfGetDB( DB_SLAVE );
+       $dbr = wfGetDB( DB_SLAVE );
        print "Finding spam on " . count($wgLocalDatabases) . " wikis\n";
        $found = false;
        foreach ( $wgLocalDatabases as $db ) {
@@ -109,4 +111,4 @@ if ( $options['all'] ) {
        }
 }
 
-?>
+