X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=c2c5ccf40e977af7bedbe91bbacbf745665de6aa;hb=d835ee699cb69d12e871a1263c237708cd9c0871;hp=2923b381dcb565fa20bac6a531e277084d9dd985;hpb=340c9530c6a599bc956da0f2b883247f1b282d5c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 2923b381dc..c2c5ccf40e 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -24,6 +24,8 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; /** @@ -82,7 +84,7 @@ 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( 'username-prefix', 'Prefix for interwiki usernames', false, true ); $this->addOption( 'no-local-users', 'Treat all usernames as interwiki. ' . 'The default is to assign edits to local users where they exist.', @@ -110,8 +112,8 @@ TEXT $this->setNsfilter( explode( '|', $this->getOption( 'namespaces' ) ) ); } - if ( $this->hasArg() ) { - $this->importFromFile( $this->getArg() ); + if ( $this->hasArg( 0 ) ) { + $this->importFromFile( $this->getArg( 0 ) ); } else { $this->importFromStdin(); } @@ -131,13 +133,13 @@ TEXT } private function getNsIndex( $namespace ) { - global $wgContLang; - $result = $wgContLang->getNsIndex( $namespace ); + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + $result = $contLang->getNsIndex( $namespace ); if ( $result !== false ) { return $result; } $ns = intval( $namespace ); - if ( strval( $ns ) === $namespace && $wgContLang->getNsText( $ns ) !== false ) { + if ( strval( $ns ) === $namespace && $contLang->getNsText( $ns ) !== false ) { return $ns; } $this->fatalError( "Unknown namespace text / index specified: $namespace" ); @@ -322,6 +324,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( @@ -343,5 +348,5 @@ TEXT } } -$maintClass = 'BackupReader'; +$maintClass = BackupReader::class; require_once RUN_MAINTENANCE_IF_MAIN;