Subins2000 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330223 )

Change subject: Disable statistics update on import with 
maintenance/importDump.php
......................................................................

Disable statistics update on import with maintenance/importDump.php

Disable updating statistics in importDump.php to quickly finish imports from 
command line.

Bug: T144600
Change-Id: Ib827c068fb20cc03aab47e3106d489f18be1dac6
---
M includes/import/WikiImporter.php
M maintenance/importDump.php
2 files changed, 29 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/330223/1

diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php
index 328cdad..4ec4cc7 100644
--- a/includes/import/WikiImporter.php
+++ b/includes/import/WikiImporter.php
@@ -45,6 +45,8 @@
        private $importTitleFactory;
        /** @var array */
        private $countableCache = [];
+       /** @var bool $disableStatisticsUpdate */
+       private $disableStatisticsUpdate = false;
 
        /**
         * Creates an ImportXMLReader drawing from the source provided
@@ -304,6 +306,13 @@
        }
 
        /**
+        * @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
         * index 0 and ForeignTitle object at index 1
@@ -381,21 +390,23 @@
                // 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] )
+                                       ] ) );
+                               }
                        }
                }
 
diff --git a/maintenance/importDump.php b/maintenance/importDump.php
index f0e0555..c3deb7f 100644
--- a/maintenance/importDump.php
+++ b/maintenance/importDump.php
@@ -283,6 +283,9 @@
                $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 );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/330223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib827c068fb20cc03aab47e3106d489f18be1dac6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Subins2000 <subins2...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to