Transforming a message uses automatically $wgTitle, which may not be set if running...
authorPlatonides <platonides@users.mediawiki.org>
Wed, 26 Jan 2011 00:23:39 +0000 (00:23 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 26 Jan 2011 00:23:39 +0000 (00:23 +0000)
Creating a new title in transformMsg() in such case. Reverting r80987 (its revert), and r80898 (workaround).

Confirmed that now both the installer and extensions/Translate/scripts/sync-group.php work.

includes/installer/Installer.php
includes/parser/Parser.php

index 9206b36..ab449c0 100644 (file)
@@ -1427,12 +1427,7 @@ abstract class Installer {
        protected function createMainpage( DatabaseInstaller $installer ) {
                $status = Status::newGood();
                try {
-                       // STUPID STUPID $wgTitle. PST calls getUserSig(), which joyfully
-                       // calls for a parsed message and uses $wgTitle. There isn't even
-                       // a signature in this...
-                       global $wgTitle;
-                       $wgTitle = Title::newMainPage();
-                       $article = new Article( $wgTitle );
+                       $article = new Article( Title::newMainPage() );
                        $article->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" .
                                                                wfMsgForContent( 'mainpagedocfooter' ),
                                                                '',
index 245aac5..3f04d31 100644 (file)
@@ -453,7 +453,7 @@ class Parser {
         * Expand templates and variables in the text, producing valid, static wikitext.
         * Also removes comments.
         */
-       function preprocess( $text, $title, $options, $revid = null ) {
+       function preprocess( $text, Title $title, ParserOptions $options, $revid = null ) {
                wfProfileIn( __METHOD__ );
                $this->startExternalParse( $title, $options, self::OT_PREPROCESS, true );
                if ( $revid !== null ) {
@@ -473,7 +473,7 @@ class Parser {
         * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
         * comments, templates, arguments, tags hooks and parser functions are untouched.
         */
-       public function getPreloadText( $text, $title, $options ) {
+       public function getPreloadText( $text, Title $title, ParserOptions $options ) {
                # Parser (re)initialisation
                $this->startExternalParse( $title, $options, self::OT_PLAIN, true );
 
@@ -4293,7 +4293,7 @@ class Parser {
         * Set up some variables which are usually set up in parse()
         * so that an external function can call some class members with confidence
         */
-       public function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
+       public function startExternalParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
                $this->setTitle( $title );
                $this->mOptions = $options;
                $this->setOutputType( $outputType );
@@ -4320,7 +4320,13 @@ class Parser {
                $executing = true;
 
                wfProfileIn( __METHOD__ );
-               $text = $this->preprocess( $text, $wgTitle, $options );
+               $title = $wgTitle;
+               if ( !$title ) {
+                       # It's not uncommon having a null $wgTitle in scripts. See r80898
+                       # Create a ghost title in such case
+                       $title = Title::newFromText( 'Dwimmerlaik' );
+               }
+               $text = $this->preprocess( $text, $title, $options );
 
                $executing = false;
                wfProfileOut( __METHOD__ );
@@ -5187,7 +5193,7 @@ class Parser {
        /**
         * strip/replaceVariables/unstrip for preprocessor regression testing
         */
-       function testSrvus( $text, $title, $options, $outputType = self::OT_HTML ) {
+       function testSrvus( $text, $title, ParserOptions $options, $outputType = self::OT_HTML ) {
                if ( !$title instanceof Title ) {
                        $title = Title::newFromText( $title );
                }