From 0dfff7a98890752133c54029f1202432549ea984 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sat, 20 Dec 2008 20:00:07 +0000 Subject: [PATCH] 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. --- includes/api/ApiParse.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 2f74226707..50b19e2169 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -49,7 +49,9 @@ class ApiParse extends ApiBase { $prop = array_flip($params['prop']); $revid = false; - global $wgParser, $wgUser; + // The parser needs $wgTitle to be set, apparently the + // $title parameter in Parser::parse isn't enough *sigh* + global $wgParser, $wgUser, $wgTitle; $popts = new ParserOptions(); $popts->setTidy(true); $popts->enableLimitReport(); @@ -66,6 +68,7 @@ class ApiParse extends ApiBase { $this->dieUsage("You don't have permission to view deleted revisions", 'permissiondenied'); $text = $rev->getText( Revision::FOR_THIS_USER ); $titleObj = $rev->getTitle(); + $wgTitle = $titleObj; $p_result = $wgParser->parse($text, $titleObj, $popts); } else @@ -111,6 +114,7 @@ class ApiParse extends ApiBase { $titleObj = Title::newFromText($title); if(!$titleObj) $titleObj = Title::newFromText("API"); + $wgTitle = $titleObj; if($params['pst'] || $params['onlypst']) $text = $wgParser->preSaveTransform($text, $titleObj, $wgUser, $popts); if($params['onlypst']) -- 2.20.1