X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=43e5060a8447ef4d6acd42af19d59ccca6b85c75;hb=0a0b02b56c2c9f03918eab099d1e196ac513fa10;hp=ea8c84bbbf7223066f61e6db86a8e66269a165aa;hpb=a56c35a226fea3a3548a0313ce8fb748cfeb3d5a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index ea8c84bbbf..43e5060a84 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -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)' ); @@ -119,7 +121,8 @@ TEXT; private function getNsIndex( $namespace ) { global $wgContLang; - if ( ( $result = $wgContLang->getNsIndex( $namespace ) ) !== false ) { + $result = $wgContLang->getNsIndex( $namespace ); + if ( $result !== false ) { return $result; } $ns = intval( $namespace ); @@ -134,16 +137,24 @@ TEXT; * @return bool */ private function skippedNamespace( $obj ) { + $title = null; if ( $obj instanceof Title ) { - $ns = $obj->getNamespace(); + $title = $obj; } elseif ( $obj instanceof Revision ) { - $ns = $obj->getTitle()->getNamespace(); + $title = $obj->getTitle(); } elseif ( $obj instanceof WikiRevision ) { - $ns = $obj->title->getNamespace(); + $title = $obj->title; } else { throw new MWException( "Cannot get namespace of object in " . __METHOD__ ); } + if ( is_null( $title ) ) { + // Probably a log entry + return false; + } + + $ns = $title->getNamespace(); + return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter ); } @@ -235,8 +246,6 @@ TEXT; } } wfWaitForSlaves(); - // XXX: Don't let deferred jobs array get absurdly large (bug 24375) - DeferredUpdates::doUpdates( 'commit' ); } function progress( $string ) { @@ -278,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' ) );