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

Revision: 99673
Author:   nikerabbit
Date:     2011-10-13 08:38:50 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
Possible fix for bug 31653

Modified Paths:
--------------
    trunk/extensions/Translate/MessageCollection.php
    trunk/extensions/Translate/tag/RenderJob.php
    trunk/extensions/Translate/tag/TPParse.php

Modified: trunk/extensions/Translate/MessageCollection.php
===================================================================
--- trunk/extensions/Translate/MessageCollection.php    2011-10-13 08:22:09 UTC 
(rev 99672)
+++ trunk/extensions/Translate/MessageCollection.php    2011-10-13 08:38:50 UTC 
(rev 99673)
@@ -188,11 +188,13 @@
 
        /**
         * Loads all message data. Must be called before accessing the messages
-        * with ArrayAccess or iteration.
+        * with ArrayAccess or iteration. Must be called before filtering for
+        * $dbtype to have an effect.
+        * @param $dbtype One of DB_* constants.
         */
-       public function loadTranslations() {
-               $this->loadData( $this->keys );
-               $this->loadInfo( $this->keys );
+       public function loadTranslations( $dbtype = DB_SLAVE ) {
+               $this->loadData( $this->keys, $dbtype );
+               $this->loadInfo( $this->keys, $dbtype );
                $this->initMessages();
        }
 
@@ -476,8 +478,9 @@
        /**
         * Loads existence and fuzzy state for given list of keys.
         * @param $keys \list{String} List of keys in database format.
+        * @param $dbtype One of DB_* constants.
         */
-       protected function loadInfo( array $keys ) {
+       protected function loadInfo( array $keys, $dbtype = DB_SLAVE ) {
                if ( $this->dbInfo !== null ) {
                        return;
                }
@@ -488,7 +491,7 @@
                        return;
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( $dbtype );
 
                $tables = array( 'page', 'revtag' );
                $fields = array( 'page_title', 'rt_type' );
@@ -509,8 +512,9 @@
        /**
         * Loads translation for given list of keys.
         * @param $keys \list{String} List of keys in database format.
+        * @param $dbtype One of DB_* constants.
         */
-       protected function loadData( $keys ) {
+       protected function loadData( $keys, $dbtype = DB_SLAVE ) {
                if ( $this->dbData !== null ) {
                        return;
                }
@@ -521,7 +525,7 @@
                        return;
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( $dbtype );
 
                $tables = array( 'page', 'revision', 'text' );
                $fields = array( 'page_title', 'rev_user_text', 'old_flags', 
'old_text' );

Modified: trunk/extensions/Translate/tag/RenderJob.php
===================================================================
--- trunk/extensions/Translate/tag/RenderJob.php        2011-10-13 08:22:09 UTC 
(rev 99672)
+++ trunk/extensions/Translate/tag/RenderJob.php        2011-10-13 08:38:50 UTC 
(rev 99673)
@@ -51,6 +51,7 @@
 
                $group = $page->getMessageGroup();
                $collection = $group->initCollection( $code );
+               $collection->loadTranslations( DB_MASTER );
 
                $text = $page->getParse()->getTranslationPageText( $collection 
);
 

Modified: trunk/extensions/Translate/tag/TPParse.php
===================================================================
--- trunk/extensions/Translate/tag/TPParse.php  2011-10-13 08:22:09 UTC (rev 
99672)
+++ trunk/extensions/Translate/tag/TPParse.php  2011-10-13 08:38:50 UTC (rev 
99673)
@@ -177,7 +177,7 @@
                // For finding the messages
                $prefix = $this->title->getPrefixedDBKey() . '/';
 
-               if ( $collection instanceOf MessageCollection ) {
+               if ( $collection instanceof MessageCollection ) {
                        $collection->filter( 'hastranslation', false );
                        $collection->loadTranslations();
                }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to