r44858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44857‎ | r44858 | r44859 >
Date:20:00, 20 December 2008
Author:catrope
Status:ok (Comments)
Tags:
Comment:
API: Fixing issue mentioned on bug 16129 comment #3: for certain inputs, action=parse dies with an internal error whining about $wgTitle not being set in OutputPage::parse(). This commit works around this by setting $wgTitle, but the parser and its friends should really leave $wgTitle alone, because people might want to parse non-$wgTitle titles, which the Parser::parse() docs suggest is possible (and it should be), but apparently isn't.
Modified paths:
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -49,7 +49,9 @@
5050 $prop = array_flip($params['prop']);
5151 $revid = false;
5252
53 - global $wgParser, $wgUser;
 53+ // The parser needs $wgTitle to be set, apparently the
 54+ // $title parameter in Parser::parse isn't enough *sigh*
 55+ global $wgParser, $wgUser, $wgTitle;
5456 $popts = new ParserOptions();
5557 $popts->setTidy(true);
5658 $popts->enableLimitReport();
@@ -66,6 +68,7 @@
6769 $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied');
6870 $text = $rev->getText( Revision::FOR_THIS_USER );
6971 $titleObj = $rev->getTitle();
 72+ $wgTitle = $titleObj;
7073 $p_result = $wgParser->parse($text, $titleObj, $popts);
7174 }
7275 else
@@ -111,6 +114,7 @@
112115 $titleObj = Title::newFromText($title);
113116 if(!$titleObj)
114117 $titleObj = Title::newFromText("API");
 118+ $wgTitle = $titleObj;
115119 if($params['pst'] || $params['onlypst'])
116120 $text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts);
117121 if($params['onlypst'])

Follow-up revisions

RevisionCommit summaryAuthorDate
r86304* (bug 28532) wfMsgExt() and wfMsgWikiHtml() use $wgOut->parse()...reedy12:43, 18 April 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   01:33, 21 December 2008

creepy :)

Status & tagging log