And while I'm a it:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 25 Dec 2011 16:36:13 +0000 (16:36 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 25 Dec 2011 16:36:13 +0000 (16:36 +0000)
* Use the commented-out code ("MW 1.6" is way old and "Revision.php 1.26" sounds like CVS)
* Don't revert to a revision whose text was deleted

maintenance/cleanupSpam.php

index 9b8e435..ca1e302 100644 (file)
@@ -94,20 +94,13 @@ class CleanupSpam extends Maintenance {
 
                $this->output( $title->getPrefixedDBkey() . " ..." );
                $rev = Revision::newFromTitle( $title );
-               $revId = $rev->getId();
-               $currentRevId = $revId;
+               $currentRevId = $rev->getId();
 
-               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 );
-                       if ( $revId ) {
-                               $rev = Revision::newFromTitle( $title, $revId );
-                       } else {
-                               $rev = false;
-                       }
+               while ( $rev && ( $rev->isDeleted( Revision::DELETED_TEXT ) || LinkFilter::matchEntry( $rev->getText() , $domain ) ) ) {
+                       $rev = $rev->getPrevious();
                }
-               if ( $revId == $currentRevId ) {
+
+               if ( $rev && $rev->getId() == $currentRevId ) {
                        // The regex didn't match the current article text
                        // This happens e.g. when a link comes from a template rather than the page itself
                        $this->output( "False match\n" );