http://www.mediawiki.org/wiki/Special:Code/MediaWiki/93744

Revision: 93744
Author:   catrope
Date:     2011-08-02 14:05:01 +0000 (Tue, 02 Aug 2011)
Log Message:
-----------
Add --no-updates flag to importDump.php that allows the user to skip updating 
the links table. On my test dataset (an old (~2 years) MediaWiki namespace dump 
of enwiki) this speeds up the import from 9m35s to 10s.

Modified Paths:
--------------
    trunk/phase3/includes/Import.php
    trunk/phase3/maintenance/importDump.php

Modified: trunk/phase3/includes/Import.php
===================================================================
--- trunk/phase3/includes/Import.php    2011-08-02 13:58:40 UTC (rev 93743)
+++ trunk/phase3/includes/Import.php    2011-08-02 14:05:01 UTC (rev 93744)
@@ -36,6 +36,7 @@
        private $mSiteInfoCallback, $mTargetNamespace, $mPageOutCallback;
        private $mDebug;
        private $mImportUploads, $mImageBasePath;
+       private $mNoUpdates = false;
 
        /**
         * Creates an ImportXMLReader drawing from the source provided
@@ -90,6 +91,13 @@
        function setDebug( $debug ) {
                $this->mDebug = $debug;
        }
+       
+       /**
+        * Set 'no updates' mode. In this mode, the link tables will not be 
updated by the importer
+        */
+       function setNoUpdates( $noupdates ) {
+               $this->mNoUpdates = $noupdates;
+       }
 
        /**
         * Sets the action to perform as each new page in the stream is reached.
@@ -453,6 +461,7 @@
                $revision->setTimestamp( $logInfo['timestamp'] );
                $revision->setParams( $logInfo['params'] );
                $revision->setTitle( Title::newFromText( $logInfo['logtitle'] ) 
);
+               $revision->setNoUpdates( $this->mNoUpdates );
 
                if ( isset( $logInfo['comment'] ) ) {
                        $revision->setComment( $logInfo['comment'] );
@@ -587,6 +596,7 @@
                if ( isset( $revisionInfo['contributor']['username'] ) ) {
                        $revision->setUserName( 
$revisionInfo['contributor']['username'] );
                }
+               $revision->setNoUpdates( $this->mNoUpdates );
 
                return $this->revisionCallback( $revision );
        }
@@ -677,6 +687,7 @@
                if ( isset( $uploadInfo['contributor']['username'] ) ) {
                        $revision->setUserName( 
$uploadInfo['contributor']['username'] );
                }
+               $revision->setNoUpdates( $this->mNoUpdates );
 
                return call_user_func( $this->mUploadCallback, $revision );
        }
@@ -853,6 +864,7 @@
        var $sha1base36 = false;
        var $isTemp = false;
        var $archiveName = '';
+       private $mNoUpdates = false;
 
        function setTitle( $title ) {
                if( is_object( $title ) ) {
@@ -926,6 +938,10 @@
        function setParams( $params ) {
                $this->params = $params;
        }
+       
+       public function setNoUpdates( $noupdates ) {
+               $this->mNoUpdates = $noupdates;
+       }
 
        /**
         * @return Title
@@ -1056,8 +1072,9 @@
                $revision->insertOn( $dbw );
                $changed = $article->updateIfNewerOn( $dbw, $revision );
 
-               if ( $changed !== false ) {
+               if ( $changed !== false && !$this->mNoUpdates ) {
                        wfDebug( __METHOD__ . ": running updates\n" );
+                       throw new MWException("BROKEN: calling 
doEditUpdates()");
                        $article->doEditUpdates( $revision, $userObj, array( 
'created' => $created, 'oldcountable' => $oldcountable ) );
                }
 

Modified: trunk/phase3/maintenance/importDump.php
===================================================================
--- trunk/phase3/maintenance/importDump.php     2011-08-02 13:58:40 UTC (rev 
93743)
+++ trunk/phase3/maintenance/importDump.php     2011-08-02 14:05:01 UTC (rev 
93744)
@@ -63,6 +63,7 @@
                $this->addOption( 'dry-run', 'Parse dump without actually 
importing pages' );
                $this->addOption( 'debug', 'Output extra verbose debug 
information' );
                $this->addOption( 'uploads', 'Process file upload data if 
included (experimental)' );
+               $this->addOption( 'no-updates', '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->addArg( 'file', 'Dump file to import [else use stdin]', 
false );
        }
@@ -243,6 +244,9 @@
                if( $this->hasOption( 'debug' ) ) {
                        $importer->setDebug( true );
                }
+               if ( $this->hasOption( 'no-updates' ) ) {
+                       $importer->setNoUpdates( true );
+               }
                $importer->setPageCallback( array( &$this, 'reportPage' ) );
                $this->importCallback =  $importer->setRevisionCallback(
                        array( &$this, 'handleRevision' ) );


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

Reply via email to