'user' => $main->getUser(),
'language' => $main->getLanguage(),
];
+ if ( $main->canUseWikiPage() ) {
+ $ctx['wikipage'] = $main->getWikiPage();
+ }
// Override
$wgTitle = $title;
$main->setRequest( $ctx['request'] );
$main->setUser( $ctx['user'] );
$main->setLanguage( $ctx['language'] );
+ if ( isset( $ctx['wikipage'] ) ) {
+ $main->setWikiPage( $ctx['wikipage'] );
+ }
return $ret;
}
$this->parser->parse( $longLine, $title, $options )->getText( [ 'unwrap' => true ] ) );
}
+ /**
+ * @covers Parser::braceSubstitution
+ * @covers SpecialPageFactory::capturePath
+ */
+ public function testSpecialPageTransclusionRestoresGlobalState() {
+ $text = "{{Special:ApiHelp/help}}";
+ $title = Title::newFromText( 'testSpecialPageTransclusionRestoresGlobalState' );
+ $options = ParserOptions::newFromUser( new User() );
+
+ RequestContext::getMain()->setTitle( $title );
+ RequestContext::getMain()->getWikiPage()->CustomTestProp = true;
+
+ $parsed = $this->parser->parse( $text, $title, $options )->getText();
+ $this->assertContains( 'apihelp-header', $parsed );
+
+ // Verify that this property wasn't wiped out by the parse
+ $this->assertTrue( RequestContext::getMain()->getWikiPage()->CustomTestProp );
+ }
+
/**
* Test the parser entry points
* @covers Parser::parse