Merge "Removed deprecated $wgMasterWaitTimeout; not used by LoadBalancer"
[lhc/web/wiklou.git] / maintenance / deleteBatch.php
index c1cc03c..e6321e1 100644 (file)
@@ -3,11 +3,11 @@
  * Deletes a batch of pages.
  * Usage: php deleteBatch.php [-u <user>] [-r <reason>] [-i <interval>] [listfile]
  * where
- *     [listfile] is a file where each line contains the title of a page to be
- *             deleted, standard input is used if listfile is not given.
- *     <user> is the username
- *     <reason> is the delete reason
- *     <interval> is the number of seconds to sleep for after each delete
+ *   [listfile] is a file where each line contains the title of a page to be
+ *     deleted, standard input is used if listfile is not given.
+ *   <user> is the username
+ *   <reason> is the delete reason
+ *   <interval> is the number of seconds to sleep for after each delete
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -79,7 +79,9 @@ class DeleteBatch extends Maintenance {
                $dbw = wfGetDB( DB_MASTER );
 
                # Handle each entry
+               // @codingStandardsIgnoreStart Ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
                for ( $linenum = 1; !feof( $file ); $linenum++ ) {
+                       // @codingStandardsIgnoreEnd
                        $line = trim( fgets( $file ) );
                        if ( $line == '' ) {
                                continue;
@@ -95,17 +97,15 @@ class DeleteBatch extends Maintenance {
                        }
 
                        $this->output( $title->getPrefixedText() );
-                       $dbw->begin( __METHOD__ );
                        if ( $title->getNamespace() == NS_FILE ) {
-                               $img = wfFindFile( $title );
+                               $img = wfFindFile( $title, array( 'ignoreRedirect' => true ) );
                                if ( $img && $img->isLocal() && !$img->delete( $reason ) ) {
                                        $this->output( " FAILED to delete associated file... " );
                                }
                        }
                        $page = WikiPage::factory( $title );
                        $error = '';
-                       $success = $page->doDeleteArticle( $reason, false, 0, false, $error, $user );
-                       $dbw->commit( __METHOD__ );
+                       $success = $page->doDeleteArticle( $reason, false, 0, true, $error, $user );
                        if ( $success ) {
                                $this->output( " Deleted!\n" );
                        } else {