Add --rootpage parameter to importDump.php
authorAndrew H <crazy4sb@gmail.com>
Sat, 26 Dec 2015 03:49:48 +0000 (03:49 +0000)
committerAndrew H <crazy4sb@gmail.com>
Sun, 27 Dec 2015 02:53:34 +0000 (02:53 +0000)
The --rootpage parameter will import pages as subpages
of a specified page.

Bug: T72272
Change-Id: Ie026b091275668765ea06e947d45bed64354f2cb

maintenance/importDump.php

index 6b7cfb6..43e5060 100644 (file)
@@ -68,6 +68,8 @@ TEXT;
                $this->addOption( 'namespaces',
                        'Import only the pages from namespaces belonging to the list of ' .
                        'pipe-separated namespace names or namespace indexes', false, true );
+               $this->addOption( 'rootpage', 'Pages will be imported as subpages of the specified page',
+                       false, true );
                $this->addOption( 'dry-run', 'Parse dump without actually importing pages' );
                $this->addOption( 'debug', 'Output extra verbose debug information' );
                $this->addOption( 'uploads', 'Process file upload data if included (experimental)' );
@@ -285,6 +287,14 @@ TEXT;
                if ( $this->hasOption( 'no-updates' ) ) {
                        $importer->setNoUpdates( true );
                }
+               if ( $this->hasOption( 'rootpage' ) ) {
+                       $statusRootPage = $importer->setTargetRootPage( $this->getOption( 'rootpage' ) );
+                       if ( !$statusRootPage->isGood() ) {
+                               // Die here so that it doesn't print "Done!"
+                               $this->error( $statusRootPage->getMessage()->text(), 1 );
+                               return false;
+                       }
+               }
                $importer->setPageCallback( array( &$this, 'reportPage' ) );
                $this->importCallback = $importer->setRevisionCallback(
                        array( &$this, 'handleRevision' ) );