+ $this->addOption( 'report',
+ 'Report position and speed after every n pages processed', false, true );
+ $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( '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)' );
+ $this->addOption( 'no-updates', 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state' );
+ $this->addOption( 'image-base-path', 'Import files from a specified path', false, true );
+ $this->addArg( 'file', 'Dump file to import [else use stdin]', false );
+ }
+
+ public function execute() {
+ if( wfReadOnly() ) {
+ $this->error( "Wiki is in read-only mode; you'll need to disable it for import to work.", true );
+ }
+
+ $this->reportingInterval = intval( $this->getOption( 'report', 100 ) );
+ if ( !$this->reportingInterval ) {
+ $this->reportingInterval = 100; // avoid division by zero
+ }
+
+ $this->dryRun = $this->hasOption( 'dry-run' );
+ $this->uploads = $this->hasOption( 'uploads' ); // experimental!
+ if ( $this->hasOption( 'image-base-path' ) ) {
+ $this->imageBasePath = $this->getOption( 'image-base-path' );
+ }
+ if ( $this->hasOption( 'namespaces' ) ) {
+ $this->setNsfilter( explode( '|', $this->getOption( 'namespaces' ) ) );
+ }
+
+ if( $this->hasArg() ) {
+ $this->importFromFile( $this->getArg() );
+ } else {
+ $this->importFromStdin();
+ }
+
+ $this->output( "Done!\n" );
+ $this->output( "You might want to run rebuildrecentchanges.php to regenerate RecentChanges\n" );
+ }
+
+ function setNsfilter( array $namespaces ) {
+ if ( count( $namespaces ) == 0 ) {
+ $this->nsFilter = false;
+ return;
+ }
+ $this->nsFilter = array_unique( array_map( array( $this, 'getNsIndex' ), $namespaces ) );