Merge "Get ConfigFactory & MainConfig from MediaWikiServices"
[lhc/web/wiklou.git] / includes / import / WikiImporter.php
index 259d514..328cdad 100644 (file)
@@ -23,6 +23,7 @@
  * @file
  * @ingroup SpecialPage
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * XML file reader for the page data importer.
@@ -59,7 +60,7 @@ class WikiImporter {
                $this->reader = new XMLReader();
                if ( !$config ) {
                        wfDeprecated( __METHOD__ . ' without a Config instance', '1.25' );
-                       $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+                       $config = MediaWikiServices::getInstance()->getMainConfig();
                }
                $this->config = $config;
 
@@ -332,8 +333,7 @@ class WikiImporter {
                }
 
                try {
-                       $dbw = wfGetDB( DB_MASTER );
-                       return $dbw->deadlockLoop( [ $revision, 'importOldRevision' ] );
+                       return $revision->importOldRevision();
                } catch ( MWContentSerializationException $ex ) {
                        $this->notice( 'import-error-unserialize',
                                $revision->getTitle()->getPrefixedText(),
@@ -351,8 +351,7 @@ class WikiImporter {
         * @return bool
         */
        public function importLogItem( $revision ) {
-               $dbw = wfGetDB( DB_MASTER );
-               return $dbw->deadlockLoop( [ $revision, 'importLogItem' ] );
+               return $revision->importLogItem();
        }
 
        /**
@@ -361,8 +360,7 @@ class WikiImporter {
         * @return bool
         */
        public function importUpload( $revision ) {
-               $dbw = wfGetDB( DB_MASTER );
-               return $dbw->deadlockLoop( [ $revision, 'importUpload' ] );
+               return $revision->importUpload();
        }
 
        /**
@@ -380,7 +378,7 @@ class WikiImporter {
                // Update article count statistics (T42009)
                // The normal counting logic in WikiPage->doEditUpdates() is designed for
                // one-revision-at-a-time editing, not bulk imports. In this situation it
-               // suffers from issues of slave lag. We let WikiPage handle the total page
+               // 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 );
@@ -840,7 +838,7 @@ class WikiImporter {
                                'text',
                                ''
                        ] ) ) &&
-                       (int)( strlen( $revisionInfo['text'] ) / 1024 ) > $wgMaxArticleSize
+                       strlen( $revisionInfo['text'] ) > $wgMaxArticleSize * 1024
                ) {
                        throw new MWException( 'The text of ' .
                                ( isset( $revisionInfo['id'] ) ?