Last modified: 2011-12-22 22:18:18 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T35318, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 33318 - Internal call to ApiParse changes caller page
Internal call to ApiParse changes caller page
Status: NEW
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-22 08:11 UTC by Vladimir Kostyukov
Modified: 2011-12-22 22:18 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Vladimir Kostyukov 2011-12-22 08:11:36 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.
Comment 1 Roan Kattouw 2011-12-22 22:18:18 UTC
Maybe this should use a fresh Parser object from a context or something,

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links