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

Change subject: Replace "Article::getContent()" deprecated in MediaWiki 1.21
......................................................................

Replace "Article::getContent()" deprecated in MediaWiki 1.21

* ApiImportTranslationMemories

Bug: T151973
Change-Id: I32ed1ed2a7d7d4f35bb9893a41089d0784322c90
---
M api/ApiImportTranslationMemories.php
1 file changed, 33 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LiveTranslate 
refs/changes/68/327268/1

diff --git a/api/ApiImportTranslationMemories.php 
b/api/ApiImportTranslationMemories.php
index 9592ca2..f00eb2b 100644
--- a/api/ApiImportTranslationMemories.php
+++ b/api/ApiImportTranslationMemories.php
@@ -12,69 +12,69 @@
  * @author Jeroen De Dauw < jeroended...@gmail.com >
  */
 class ApiImportTranslationMemories extends ApiBase {
-       
+
        public function __construct( $main, $action ) {
                parent::__construct( $main, $action );
        }
-       
+
        public function execute() {
                if ( !$this->getUser()->isAllowed( 'managetms' ) || 
$this->getUser()->isBlocked() ) {
                        $this->dieUsageMsg( array( 'badaccess-groups' ) );
                }
-               
+
                $params = $this->extractRequestParams();
-               
+
                // In MW 1.17 and above ApiBase::PARAM_REQUIRED can be used, 
this is for b/c with 1.16.
                foreach ( array( 'source' ) as $requiredParam ) {
                        if ( !isset( $params[$requiredParam] ) ) {
                                $this->dieUsageMsg( array( 'missingparam', 
$requiredParam ) );
-                       }                       
+                       }
                }
 
                foreach ( $params['source'] as $location ) {
                        $text = false;
-                       
+
                        $dbr = wfGetDB( DB_SLAVE );
-                       
+
                        $res = $dbr->select(
                                'live_translate_memories',
                                array( 'memory_id', 'memory_local', 
'memory_type' ),
                                array( 'memory_location' => $location ),
                                __METHOD__,
                                array( 'LIMIT' => '1' )
-                       );                      
-                       
+                       );
+
                        foreach ( $res as $tm ) {
                                if ( $tm->memory_local != '0' ) {
                                        // Obtain the contents of the article.
                                        $title = Title::newFromText( $location, 
NS_MAIN );
-                                       
+
                                        if ( is_object( $title ) && 
$title->exists() ) {
-                                               $article = new Article( $title 
);
-                                               $text = $article->getContent();
-                                       }                               
+                                               $page = WikiPage::factory( 
$title );
+                                               $text = 
$page->getContent()->getNativeData();
+                                       }
                                }
                                else {
                                        // Make an HTTP request to get the file 
contents. False is returned on failiure.
                                        $text = Http::get( $location );
                                }
-                               
+
                                if ( $text !== false ) {
                                        // If the text was obtained, parse it 
to a translation memory and import it into the db.
                                        $parser = LTTMParser::newFromType( 
$tm->memory_type );
                                        $this->doTMImport( $parser->parse( 
$text ), $tm->memory_id );
-                               }                               
-                               
+                               }
+
                                break;
                        }
                }
        }
-       
+
        /**
         * Imports a translation memory into the database.
-        * 
+        *
         * @since 0.4
-        * 
+        *
         * @param LTTranslationMemory $tm
         * @param integer $memoryId
         */
@@ -97,10 +97,10 @@
                        if ( $GLOBALS['egLTRequireSignificance'] && 
!$tu->isSignificant() ) {
                                continue;
                        }
-                       
+
                        foreach ( $tu->getVariants() as $language => 
$translations ) {
                                $primary = 1;
-                               
+
                                foreach ( $translations as $translation ) {
                                        $dbw->insert(
                                                'live_translate',
@@ -116,10 +116,10 @@
                                        $primary = 0;
                                }
                        }
-                       
+
                        $wordId++;
                }
-               
+
                $dbw->update(
                        'live_translate_memories',
                        array(
@@ -132,24 +132,24 @@
 
                $dbw->endAtomic( __METHOD__ );
        }
-       
+
        /**
         * Cleans the language code.
-        * 
+        *
         * @since 0.4
-        * 
+        *
         * @param string language
-        * 
+        *
         * @return string
         */
        protected function cleanLanguage( $language ) {
                $language = strtolower( $language );
                $mappings = LiveTranslateFunctions::getInputLangMapping();
-               
+
                if ( array_key_exists( $language, $mappings ) ) {
                        $language = $mappings[$language];
                }
-               
+
                return $language;
        }
 
@@ -162,13 +162,13 @@
                        ),
                );
        }
-       
+
        public function getParamDescription() {
                return array(
                        'source' => 'Location of the translation memory. 
Multiple sources can be provided using the | delimiter.',
                );
        }
-       
+
        public function getDescription() {
                return array(
                        'Imports one or more translation memories.'
@@ -181,5 +181,5 @@
                        
'api.php?action=importtms&source=http://localhost/tmx.xml|http://localhost/google.csv|Live
 Translate Dictionary',
                );
        }
-       
-}
\ No newline at end of file
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32ed1ed2a7d7d4f35bb9893a41089d0784322c90
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LiveTranslate
Gerrit-Branch: master
Gerrit-Owner: Divadsn <divad.nnamtd...@gmail.com>

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

Reply via email to