X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=918c1ab98bfdac1cd13e4641fa10df7292f97958;hb=0c77841534d9139b0042696fe015a15d3e349ef5;hp=206c7ee6aed437ddccc92481d5fb8a7812b5c210;hpb=03cd9495a4dac1c1cda738d52e74b553b977beb8;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 206c7ee6ae..918c1ab98b 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -82,12 +82,18 @@ 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 ); } 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->fatalError( "Wiki is in read-only mode; you'll need to disable it for import to work." ); } $this->reportingInterval = intval( $this->getOption( 'report', 100 ) ); @@ -134,11 +140,12 @@ TEXT if ( strval( $ns ) === $namespace && $wgContLang->getNsText( $ns ) !== false ) { return $ns; } - $this->error( "Unknown namespace text / index specified: $namespace", true ); + $this->fatalError( "Unknown namespace text / index specified: $namespace" ); } /** * @param Title|Revision $obj + * @throws MWException * @return bool */ private function skippedNamespace( $obj ) { @@ -295,11 +302,17 @@ 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() ) { // Die here so that it doesn't print "Done!" - $this->error( $statusRootPage->getMessage()->text(), 1 ); + $this->fatalError( $statusRootPage->getMessage()->text() ); return false; } } @@ -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(