Kunalgrover05 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137915

Change subject: Patch to load language for DB
......................................................................

Patch to load language for DB

Patch to fix loading of language from DB on calling getContentLanguage()
Fixes API with DB

Change-Id: Ibf408ba4d143c1079677b006c4baca6e4b9722f8
---
M includes/Title.php
1 file changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/15/137915/1

diff --git a/includes/Title.php b/includes/Title.php
index 88ea65e..6b068bb 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -423,6 +423,7 @@
         * @param stdClass|bool $row Database row
         */
        public function loadFromRow( $row ) {
+               global $wgLanguageCode;
                if ( $row ) { // page found
                        if ( isset( $row->page_id ) ) {
                                $this->mArticleID = (int)$row->page_id;
@@ -444,6 +445,7 @@
                        if ( isset( $row->page_lang ) ) {
                                $this->mDBPageLanguage = 
(string)$row->page_lang;
                        }
+                       $mPageLanguage[1] = $wgLanguageCode;
                } else { // page not found
                        $this->mArticleID = 0;
                        $this->mLength = 0;
@@ -4992,8 +4994,21 @@
                        $settings = $contentHandler->getPageLanguageSettings( 
$settings, $this );
                }
 
-               if ( !$this->mPageLanguage || $this->mPageLanguage[1] !== 
$wgLanguageCode ) {
-                       // NOTE: ContentHandler::getPageLanguage() may need to 
load the
+               // If mPageLanguage is false, means we haven't checked DB yet 
for page language
+               if ( !$this->mPageLanguage ) {
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $row = $dbr->selectRow(
+                               'page',
+                               'page_lang',
+                               array( 'page_id' => $this->getArticleID() ),
+                               __METHOD__
+                       );
+                       $this->mDBPageLanguage = $row->page_lang;
+                       $this->mPageLanguage[1] = $wgLanguageCode;
+               }
+
+               // If mPageLanguage[0] is set, no need to run this again
+               if ( !isset( $this->mPageLanguage[0] ) || 
$this->mPageLanguage[1] !== $wgLanguageCode ) {
                        // content to determine the page language!
                        // Checking $wgLanguageCode hasn't changed for the 
benefit of unit
                        // tests.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf408ba4d143c1079677b006c4baca6e4b9722f8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kunalgrover05 <kunalgrove...@gmail.com>

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

Reply via email to