private $importTitleFactory;
/** @var array */
private $countableCache = [];
+ /** @var bool */
+ private $disableStatisticsUpdate = false;
/**
* Creates an ImportXMLReader drawing from the source provided
$this->mImportUploads = $import;
}
+ /**
+ * Statistics update can cause a lot of time
+ * @since 1.29
+ */
+ public function disableStatisticsUpdate() {
+ $this->disableStatisticsUpdate = true;
+ }
+
/**
* Default per-page callback. Sets up some things related to site statistics
* @param array $titleAndForeignTitle Two-element array, with Title object at
// suffers from issues of replica DB lag. We let WikiPage handle the total page
// and revision count, and we implement our own custom logic for the
// article (content page) count.
- $page = WikiPage::factory( $title );
- $page->loadPageData( 'fromdbmaster' );
- $content = $page->getContent();
- if ( $content === null ) {
- wfDebug( __METHOD__ . ': Skipping article count adjustment for ' . $title .
- ' because WikiPage::getContent() returned null' );
- } else {
- $editInfo = $page->prepareContentForEdit( $content );
- $countKey = 'title_' . $title->getPrefixedText();
- $countable = $page->isCountable( $editInfo );
- if ( array_key_exists( $countKey, $this->countableCache ) &&
- $countable != $this->countableCache[$countKey] ) {
- DeferredUpdates::addUpdate( SiteStatsUpdate::factory( [
- 'articles' => ( (int)$countable - (int)$this->countableCache[$countKey] )
- ] ) );
+ if ( !$this->disableStatisticsUpdate ) {
+ $page = WikiPage::factory( $title );
+ $page->loadPageData( 'fromdbmaster' );
+ $content = $page->getContent();
+ if ( $content === null ) {
+ wfDebug( __METHOD__ . ': Skipping article count adjustment for ' . $title .
+ ' because WikiPage::getContent() returned null' );
+ } else {
+ $editInfo = $page->prepareContentForEdit( $content );
+ $countKey = 'title_' . $title->getPrefixedText();
+ $countable = $page->isCountable( $editInfo );
+ if ( array_key_exists( $countKey, $this->countableCache ) &&
+ $countable != $this->countableCache[$countKey] ) {
+ DeferredUpdates::addUpdate( SiteStatsUpdate::factory( [
+ 'articles' => ( (int)$countable - (int)$this->countableCache[$countKey] )
+ ] ) );
+ }
}
}
}
$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 ) {
$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 );
}