X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportDump.php;h=802619e5733988b9955001600cbaf25a75cb6275;hb=1a2ef297eb1720bd482d8112e9f3c778243695ec;hp=3bf8b272ff07674af520dfbf163e8cfe62804fcf;hpb=554ca56fd5e76b0216c09543d447dbecd5773202;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 3bf8b272ff..802619e573 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -80,6 +80,7 @@ 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->addArg( 'file', 'Dump file to import [else use stdin]', false ); } @@ -109,7 +110,8 @@ TEXT } $this->output( "Done!\n" ); - $this->output( "You might want to run rebuildrecentchanges.php to regenerate RecentChanges\n" ); + $this->output( "You might want to run rebuildrecentchanges.php to regenerate RecentChanges,\n" ); + $this->output( "and initSiteStats.php to update page and revision counts\n" ); } function setNsfilter( array $namespaces ) { @@ -118,7 +120,7 @@ TEXT return; } - $this->nsFilter = array_unique( array_map( array( $this, 'getNsIndex' ), $namespaces ) ); + $this->nsFilter = array_unique( array_map( [ $this, 'getNsIndex' ], $namespaces ) ); } private function getNsIndex( $namespace ) { @@ -205,7 +207,7 @@ TEXT // call_user_func( $this->uploadCallback, $revision ); $dbw = $this->getDB( DB_MASTER ); - return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); + return $dbw->deadlockLoop( [ $revision, 'importUpload' ] ); } } @@ -283,6 +285,9 @@ TEXT $source = new ImportStreamSource( $handle ); $importer = new WikiImporter( $source, $this->getConfig() ); + // Updating statistics require a lot of time so disable it + $importer->disableStatisticsUpdate(); + if ( $this->hasOption( 'debug' ) ) { $importer->setDebug( true ); } @@ -297,13 +302,18 @@ TEXT return false; } } - $importer->setPageCallback( array( $this, 'reportPage' ) ); + 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( - array( $this, 'handleRevision' ) ); + [ $this, 'handleRevision' ] ); $this->uploadCallback = $importer->setUploadCallback( - array( $this, 'handleUpload' ) ); + [ $this, 'handleUpload' ] ); $this->logItemCallback = $importer->setLogItemCallback( - array( $this, 'handleLogItem' ) ); + [ $this, 'handleLogItem' ] ); if ( $this->uploads ) { $importer->setImportUploads( true ); }