Page MenuHomePhabricator

addWikiText breaks multiply transcluded specialpages
Closed, DeclinedPublic

Description

Author: darren.edmundson

Description:
If you have a specialpage which uses $wgOut->addWikiText(), as recommended on
http://meta.wikimedia.org/w/index.php/Writing_a_new_special_page#OutputPage-
.3EaddWikiText.28.29 , and that page is transcluded into a page more than once
(or two such pages are transcluded, etc), then all but the last transclusion
are displayed as the "\07UNIQ-" replacement token rather than the page output.

This appears to be caused by OutputPage::addWikiText requesting the parser
state be cleared after execution, removing the earlier transcluded HTML from
the replacement table before it's actually substituted in the document.

As a workaround for my own use, I've written my own MySpecialPage->addWikiText
() which doesn't clear the state (but may well break other things) - but if
this is the preferred(/documented) way of writing special pages, then it may
need fixing for other people too.

I first saw this when trying to transclude multiple different subpages of my
IncludableSpecialPage, but have since confirmed it happens in the more general
case. Predictably $wgOut->addHTML() does not cause this problem as the parser
is not invoked.


Version: 1.9.x
Severity: normal

Details

Reference
bz9762

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:37 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz9762.
bzimport added a subscriber: Unknown Object (MLST).

mati wrote:

Probably the cleanest way for getting around this bug without losing the ability to use wiki syntax is writing your own small function that looks something like this:
function addText( $text ) {

global $wgTitle, $wgOut, $wgParser;
$po = $wgParser->parse( $text, $wgTitle, $wgParser->mOptions, false, false );
$wgOut->addHTML( $po->getText() );

}

Then simply use this function instead of addWikiText.

Just use wfMsgExt with the parse option.

Umherirrender edited subscribers, added: Umherirrender; removed: wikibugs-l-list.

addWikiText was removed.