From 90694b1ffd57a3fd68e554296612ad8fb2a304f7 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 26 Jan 2011 00:23:39 +0000 Subject: [PATCH] Transforming a message uses automatically $wgTitle, which may not be set if running from eg. a script, usecase broken by r80819. 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 | 7 +------ includes/parser/Parser.php | 16 +++++++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 9206b36cba..ab449c04bb 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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' ), '', diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 245aac5e6e..3f04d31e92 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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 { * , 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 ); } -- 2.20.1