Move up to date the parser test expectation.
[lhc/web/wiklou.git] / maintenance / deleteBatch.php
index 0d6dac9..120ed7e 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup Maintenance
  */
  
-require_once( "Maintenance.php" );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 class DeleteBatch extends Maintenance {
        
@@ -37,7 +37,7 @@ class DeleteBatch extends Maintenance {
                $this->addOption( 'u', "User to perform deletion", false, true );
                $this->addOption( 'r', "Reason to delete page", false, true );
                $this->addOption( 'i', "Interval to sleep between deletions" );
-               $this->addArgs( array( 'listfile' ) );
+               $this->addArg( 'listfile', 'File with titles to delete, separated by newlines', false );
        }
        
        public function execute() {
@@ -51,14 +51,14 @@ class DeleteBatch extends Maintenance {
                $user = $this->getOption( 'u', 'Delete page script' );
                $reason = $this->getOption( 'r', '' );
                $interval = $this->getOption( 'i', 0 );
-               if( $this->hasArg() ) {
+               if ( $this->hasArg() ) {
                        $file = fopen( $this->getArg(), 'r' );
                } else {
                        $file = $this->getStdin();
                }
 
                # Setup
-               if( !$file ) {
+               if ( !$file ) {
                        $this->error( "Unable to read file, exiting", true );
                }
                $wgUser = User::newFromName( $user );
@@ -75,7 +75,7 @@ class DeleteBatch extends Maintenance {
                                $this->output( "Invalid title '$line' on line $linenum\n" );
                                continue;
                        }
-                       if( !$page->exists() ) {
+                       if ( !$page->exists() ) {
                                $this->output( "Skipping nonexistent page '$line'\n" );
                                continue;
                        }
@@ -83,17 +83,17 @@ class DeleteBatch extends Maintenance {
        
                        $this->output( $page->getPrefixedText() );
                        $dbw->begin();
-                       if( $page->getNamespace() == NS_FILE ) {
+                       if ( $page->getNamespace() == NS_FILE ) {
                                $art = new ImagePage( $page );
                                $img = wfFindFile( $art->mTitle );
-                               if( !$img || !$img->delete( $reason ) ) {
+                               if ( !$img || !$img->delete( $reason ) ) {
                                        $this->output( "FAILED to delete image file... " );
                                }
                        } else {
                                $art = new Article( $page );
                        }
                        $success = $art->doDeleteArticle( $reason );
-                       $dbw->immediateCommit();
+                       $dbw->commit();
                        if ( $success ) {
                                $this->output( "\n" );
                        } else {