X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=b6bbc2a6d60009ac288fdd1d5e78eb7276a8b301;hb=10f187821e9d9b1db36cabf7a6902ef694c7e9ba;hp=6717a8ebde04654ac82004eb30d381760834bbc3;hpb=2c8f7978df47f338ee6e245e3efba6175ba425e9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 6717a8ebde..b6bbc2a6d6 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -37,6 +37,7 @@ class BackupReader extends Maintenance { public $revCount = 0; public $dryRun = false; public $uploads = false; + protected $uploadCount = 0; public $imageBasePath = false; public $nsFilter = false; @@ -80,12 +81,19 @@ TEXT '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->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 ) ); @@ -132,7 +140,7 @@ 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" ); } /** @@ -293,14 +301,25 @@ 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; } } + if ( $this->hasOption( 'skip-to' ) ) { + $nthPage = (int)$this->getOption( 'skip-to' ); + $importer->setPageOffset( $nthPage ); + $this->pageCount = $nthPage - 1; + } $importer->setPageCallback( [ $this, 'reportPage' ] ); $this->importCallback = $importer->setRevisionCallback( [ $this, 'handleRevision' ] );