ParserTestRunner::addArticle() set a dummy $wgParser to ease test
running. However if doEditContent() fails, it would abort and never
restore $wgParser.
Make sure the restoration is done even on exception.
I caught that one while running parser tests with Scribunto and Cite. My
setup lacked a luastandalone which causes Scribunto to throw an
exception. When the Cite tests are run, the MessageCache parser ended up
using $wgParser = ParserTestMockParser;
Change-Id: I33a0a5c1f40f197405d40b7925cc043342e6757e
// get a reference to the mock object.
MessageCache::singleton()->getParser();
$restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
// get a reference to the mock object.
MessageCache::singleton()->getParser();
$restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
- $status = $page->doEditContent(
- ContentHandler::makeContent( $text, $title ),
- '',
- EDIT_NEW | EDIT_INTERNAL
- );
- $restore();
+ try {
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( $text, $title ),
+ '',
+ EDIT_NEW | EDIT_INTERNAL
+ );
+ } finally {
+ $restore();
+ }
if ( !$status->isOK() ) {
throw new MWException( $status->getWikiText( false, false, 'en' ) );
if ( !$status->isOK() ) {
throw new MWException( $status->getWikiText( false, false, 'en' ) );