private $mNoticeCallback, $mDebug;
private $mImportUploads, $mImageBasePath;
private $mNoUpdates = false;
+ private $pageOffset = 0;
/** @var Config */
private $config;
/** @var ImportTitleFactory */
$this->mNoUpdates = $noupdates;
}
+ /**
+ * Sets 'pageOffset' value. So it will skip the first n-1 pages
+ * and start from the nth page. It's 1-based indexing.
+ * @param int $nthPage
+ * @since 1.29
+ */
+ function setPageOffset( $nthPage ) {
+ $this->pageOffset = $nthPage;
+ }
+
/**
* Set a callback that displays notice messages
*
$keepReading = $this->reader->read();
$skip = false;
$rethrow = null;
+ $pageCount = 0;
try {
while ( $keepReading ) {
$tag = $this->reader->localName;
+ if ( $this->pageOffset ) {
+ if ( $tag === 'page' ) {
+ $pageCount++;
+ }
+ if ( $pageCount < $this->pageOffset ) {
+ $keepReading = $this->reader->next();
+ continue;
+ }
+ }
$type = $this->reader->nodeType;
if ( !Hooks::run( 'ImportHandleToplevelXMLTag', [ $this ] ) ) {
'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 );
}
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' ] );