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

Revision: 70149
Author:   nikerabbit
Date:     2010-07-29 18:01:40 +0000 (Thu, 29 Jul 2010)

Log Message:
-----------
Tidy WikiPageMessageGroup

Delay constructing the title object. This also prevents an
error when serializing and using sqlite as db. There are
still plenty of cases when serialization can fail.

Modified Paths:
--------------
    trunk/extensions/Translate/MessageGroups.php

Modified: trunk/extensions/Translate/MessageGroups.php
===================================================================
--- trunk/extensions/Translate/MessageGroups.php        2010-07-29 17:58:02 UTC 
(rev 70148)
+++ trunk/extensions/Translate/MessageGroups.php        2010-07-29 18:01:40 UTC 
(rev 70149)
@@ -731,31 +731,34 @@
 }
 
 class WikiPageMessageGroup extends WikiMessageGroup {
-       protected $type = 'mediawiki';
+       protected $title;
 
-       public $title;
-
        public function __construct( $id, $source ) {
                $this->id = $id;
-               $title = Title::newFromText( $source );
+               $this->title = $source;
+               $this->namespaces = array( NS_TRANSLATIONS, 
NS_TRANSLATIONS_TALK );
+       }
 
-               if ( !$title ) {
-                       throw new MWException( 'Invalid title' );
+       public function getTitle() {
+               if ( is_string( $this->title ) ) {
+                       $this->title = Title::newFromText( $this->title );
                }
+               return $this->title;
+       }
 
-               $this->title = $title;
-               $this->namespaces = array( NS_TRANSLATIONS, 
NS_TRANSLATIONS_TALK );
+       public function getType() {
+               return 'mediawiki';
        }
 
        public function getDefinitions() {
                $dbr = wfGetDB( DB_SLAVE );
                $tables = 'translate_sections';
                $vars = array( 'trs_key', 'trs_text' );
-               $conds = array( 'trs_page' => $this->title->getArticleId() );
+               $conds = array( 'trs_page' => $this->getTitle()->getArticleId() 
);
                $res = $dbr->select( $tables, $vars, $conds, __METHOD__ );
 
                $defs = array();
-               $prefix = $this->title->getPrefixedDBKey() . '/';
+               $prefix = $this->getTitle()->getPrefixedDBKey() . '/';
                $re = '~<tvar\|([^>]+)>(.*?)</>~u';
 
                foreach ( $res as $r ) {
@@ -830,6 +833,7 @@
                $target = SpecialPage::getTitleFor( 'MyLanguage', $title 
)->getPrefixedText();
                return wfMsgNoTrans( 'translate-tag-page-desc', $title, $target 
);
        }
+
 }
 
 class MessageGroups {
@@ -989,8 +993,6 @@
        public $classes;
        private function __construct() {
                self::init();
-
-
        }
 
        public static function singleton() {



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

Reply via email to