X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=965906f2292a1395e529cc8d271f4af5316c5466;hb=1797b20c8e675d92594be2a6b0c2f319f11026b0;hp=cf0e7d83caf9b7216159321501dc55f7f020c480;hpb=d75c150177fbc2c5a818ee6735d41596bb631a8a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index cf0e7d83ca..965906f229 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -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;