Hard deprecate Parser::disableCache()
[lhc/web/wiklou.git] / maintenance / moveBatch.php
index fa25a06..b54ed45 100644 (file)
@@ -35,6 +35,8 @@
  * e.g. immobile_namespace for namespaces which can't be moved
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -65,8 +67,8 @@ class MoveBatch extends Maintenance {
                $reason = $this->getOption( 'r', '' );
                $interval = $this->getOption( 'i', 0 );
                $noredirects = $this->hasOption( 'noredirects' );
-               if ( $this->hasArg() ) {
-                       $file = fopen( $this->getArg(), 'r' );
+               if ( $this->hasArg( 0 ) ) {
+                       $file = fopen( $this->getArg( 0 ), 'r' );
                } else {
                        $file = $this->getStdin();
                }
@@ -86,9 +88,7 @@ class MoveBatch extends Maintenance {
 
                # Setup complete, now start
                $dbw = $this->getDB( DB_MASTER );
-               // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
                for ( $linenum = 1; !feof( $file ); $linenum++ ) {
-                       // @codingStandardsIgnoreEnd
                        $line = fgets( $file );
                        if ( $line === false ) {
                                break;
@@ -107,10 +107,11 @@ class MoveBatch extends Maintenance {
 
                        $this->output( $source->getPrefixedText() . ' --> ' . $dest->getPrefixedText() );
                        $this->beginTransaction( $dbw, __METHOD__ );
-                       $mp = new MovePage( $source, $dest );
+                       $mp = MediaWikiServices::getInstance()->getMovePageFactory()
+                               ->newMovePage( $source, $dest );
                        $status = $mp->move( $wgUser, $reason, !$noredirects );
                        if ( !$status->isOK() ) {
-                               $this->output( "\nFAILED: " . $status->getWikiText( false, false, 'en' ) );
+                               $this->output( "\nFAILED: " . $status->getMessage( false, false, 'en' )->text() );
                        }
                        $this->commitTransaction( $dbw, __METHOD__ );
                        $this->output( "\n" );
@@ -118,10 +119,9 @@ class MoveBatch extends Maintenance {
                        if ( $interval ) {
                                sleep( $interval );
                        }
-                       wfWaitForSlaves();
                }
        }
 }
 
-$maintClass = "MoveBatch";
+$maintClass = MoveBatch::class;
 require_once RUN_MAINTENANCE_IF_MAIN;