Last modified: 2011-12-22 22:18:18 UTC
I am using ApiMain class in my own MediaWiki extension. I want to parse content of some wiki pages from my site and I use ApiMain like following: $innerRequest = new ApiMain(new FauxRequest(array( "action" => "parse", "pageid" => 223, "prop" => "wikitext", "format" => "php" ))); $innerRequest->execute(); $data = $innerRequest->getResultData(); And if I activate my extension in any page like: {{#my_own_extension:}} caller page will change content (header, category) to parsed paged. Its behavior very strange. I've found following code in ApiParse.php (method getParsedSectionOrText): 323 $pout = $articleObj->getParserOutput(); 324 if ( $getWikitext ) { 325 $rev = Revision::newFromTitle( $titleObj ); 326 if ( $rev ) { 327 $this->text = $rev->getText(); 328 } 329 } 330 return $pout; See line 323: method getParserOutput() uses global $wgParser and it changes content of caller page. It seems to me that It should use clone of global parser (or instance) - not original. Content of caller page shouldn't change.
Maybe this should use a fresh Parser object from a context or something,