Add @covers tags for parser tests
[lhc/web/wiklou.git] / maintenance / importDump.php
index cf0e7d8..965906f 100644 (file)
@@ -82,6 +82,12 @@ TEXT
                );
                $this->addOption( 'image-base-path', 'Import files from a specified path', false, true );
                $this->addOption( 'skip-to', 'Start from nth page by skipping first n-1 pages', false, true );
+               $this->addOption( 'username-interwiki', 'Use interwiki usernames with this prefix', false, true );
+               $this->addOption( 'no-local-users',
+                       'Treat all usernames as interwiki. ' .
+                       'The default is to assign edits to local users where they exist.',
+                       false, false
+               );
                $this->addArg( 'file', 'Dump file to import [else use stdin]', false );
        }
 
@@ -139,6 +145,7 @@ TEXT
 
        /**
         * @param Title|Revision $obj
+        * @throws MWException
         * @return bool
         */
        private function skippedNamespace( $obj ) {
@@ -295,6 +302,12 @@ TEXT
                if ( $this->hasOption( 'no-updates' ) ) {
                        $importer->setNoUpdates( true );
                }
+               if ( $this->hasOption( 'username-prefix' ) ) {
+                       $importer->setUsernamePrefix(
+                               $this->getOption( 'username-prefix' ),
+                               !$this->hasOption( 'no-local-users' )
+                       );
+               }
                if ( $this->hasOption( 'rootpage' ) ) {
                        $statusRootPage = $importer->setTargetRootPage( $this->getOption( 'rootpage' ) );
                        if ( !$statusRootPage->isGood() ) {
@@ -309,6 +322,9 @@ TEXT
                        $this->pageCount = $nthPage - 1;
                }
                $importer->setPageCallback( [ $this, 'reportPage' ] );
+               $importer->setNoticeCallback( function ( $msg, $params ) {
+                       echo wfMessage( $msg, $params )->text() . "\n";
+               } );
                $this->importCallback = $importer->setRevisionCallback(
                        [ $this, 'handleRevision' ] );
                $this->uploadCallback = $importer->setUploadCallback(
@@ -330,5 +346,5 @@ TEXT
        }
 }
 
-$maintClass = 'BackupReader';
+$maintClass = BackupReader::class;
 require_once RUN_MAINTENANCE_IF_MAIN;