r81011 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81010‎ | r81011 | r81012 >
Date:00:23, 26 January 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -453,7 +453,7 @@
454454 * Expand templates and variables in the text, producing valid, static wikitext.
455455 * Also removes comments.
456456 */
457 - function preprocess( $text, $title, $options, $revid = null ) {
 457+ function preprocess( $text, Title $title, ParserOptions $options, $revid = null ) {
458458 wfProfileIn( __METHOD__ );
459459 $this->startExternalParse( $title, $options, self::OT_PREPROCESS, true );
460460 if ( $revid !== null ) {
@@ -473,7 +473,7 @@
474474 * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
475475 * comments, templates, arguments, tags hooks and parser functions are untouched.
476476 */
477 - public function getPreloadText( $text, $title, $options ) {
 477+ public function getPreloadText( $text, Title $title, ParserOptions $options ) {
478478 # Parser (re)initialisation
479479 $this->startExternalParse( $title, $options, self::OT_PLAIN, true );
480480
@@ -4293,7 +4293,7 @@
42944294 * Set up some variables which are usually set up in parse()
42954295 * so that an external function can call some class members with confidence
42964296 */
4297 - public function startExternalParse( &$title, $options, $outputType, $clearState = true ) {
 4297+ public function startExternalParse( Title $title = null, ParserOptions $options, $outputType, $clearState = true ) {
42984298 $this->setTitle( $title );
42994299 $this->mOptions = $options;
43004300 $this->setOutputType( $outputType );
@@ -4320,7 +4320,13 @@
43214321 $executing = true;
43224322
43234323 wfProfileIn( __METHOD__ );
4324 - $text = $this->preprocess( $text, $wgTitle, $options );
 4324+ $title = $wgTitle;
 4325+ if ( !$title ) {
 4326+ # It's not uncommon having a null $wgTitle in scripts. See r80898
 4327+ # Create a ghost title in such case
 4328+ $title = Title::newFromText( 'Dwimmerlaik' );
 4329+ }
 4330+ $text = $this->preprocess( $text, $title, $options );
43254331
43264332 $executing = false;
43274333 wfProfileOut( __METHOD__ );
@@ -5187,7 +5193,7 @@
51885194 /**
51895195 * strip/replaceVariables/unstrip for preprocessor regression testing
51905196 */
5191 - function testSrvus( $text, $title, $options, $outputType = self::OT_HTML ) {
 5197+ function testSrvus( $text, $title, ParserOptions $options, $outputType = self::OT_HTML ) {
51925198 if ( !$title instanceof Title ) {
51935199 $title = Title::newFromText( $title );
51945200 }
Index: trunk/phase3/includes/installer/Installer.php
@@ -1427,12 +1427,7 @@
14281428 protected function createMainpage( DatabaseInstaller $installer ) {
14291429 $status = Status::newGood();
14301430 try {
1431 - // STUPID STUPID $wgTitle. PST calls getUserSig(), which joyfully
1432 - // calls for a parsed message and uses $wgTitle. There isn't even
1433 - // a signature in this...
1434 - global $wgTitle;
1435 - $wgTitle = Title::newMainPage();
1436 - $article = new Article( $wgTitle );
 1431+ $article = new Article( Title::newMainPage() );
14371432 $article->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" .
14381433 wfMsgForContent( 'mainpagedocfooter' ),
14391434 '',

Follow-up revisions

RevisionCommit summaryAuthorDate
r814021.17: MFT r79915, r79957, r79964, r79990, r80687, r80999, r81006, r81011, r81...catrope16:18, 2 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80819Add types to prototypes.platonides16:11, 23 January 2011
r80898Workaround null Title error in parser during main page creation. Used $wgTitl...demon19:09, 24 January 2011
r80987revert r80819 for now so we can use phpunit...hashar20:37, 25 January 2011

Comments

#Comment by Hashar (talk | contribs)   20:56, 26 January 2011

Works for me.

#Comment by Yaron Koren (talk | contribs)   22:13, 11 April 2011

Platonides - just to be clear, was the change of the $title parameter of startExternalParse() from a reference to a value done on purpose?

#Comment by Werdna (talk | contribs)   03:38, 2 March 2012

wtf is Dwimmerlaik? :))

#Comment by VasilievVV (talk | contribs)   03:40, 2 March 2012

Pop culture reference.

#Comment by Platonides (talk | contribs)   21:03, 4 March 2012

According to certain encyclopedia, dwimmerlaik is a word in the speech of Rohan meaning "spectre".

There is a hint in the comment above on how it's a "ghost title". Thus being an appropiate name :)

Status & tagging log