https://bugzilla.wikimedia.org/show_bug.cgi?id=36140
--- Comment #1 from Dmitriy Sintsov <[email protected]> 2012-04-23 10:03:12 UTC --- Surprisingly, when I switched to parser function, UNIQ markers in parser output did not disappear. After trying different parser function outputs, I remembered that I selectively parse parts of user input as wikitext. Originally I used an instance of Parser and PPFrame supplied to function hook, stored as static members of my class: static function parseWikiText( $text ) { return self::$parser->recursiveTagParse( $text, self::$frame ); } however, while italics were parsed fine, wikilinks were removed. It probably was too early stage of parsing to produce html anchors. So, I switched to something like this, which used to work in 1.15 I think: static function parse( $text ) { return self::$parser->parse( $text, self::$parser->getTitle(), new ParserOptions() )->getText(); } It worked fine at the first sight: links were processed to anchors. However tests with section headers revealed non-replaced UNIQ markers. When replaced to "stub" method, UNIQ markers disappeared: static function parse( $text ) { return $text; } Call to Parser::parse at the stage of functions processing incorrectly changed the state of Parser, so UNIQ markers were produced. I grepped through the whole svn base of MediaWiki extensions and found the solution in Extension:Semantic Maps: $parser = version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ? $wgParser : clone $wgParser; It was not necessary to clone Parser, however since 1.18 it is! With cloned Parser, UNIQ markers did not appear (because the Parser is separate instance) and wiki links [[...]] also were processed correctly (and stored in html5 data attribute). I cloned the instance supplied to 'ParserFirstCallInit' hook handler, not the $wgParser; but they are probably the same. Also I cloned unconditionally, because this extension I am developing is for 1.18+. If there is better way of processing wikitext with wikilinks to output html in parser function, please let me know. Because cloning of Parser is probably not the best way (Parser is large enough). Why didn't I keep function input parts as wikitext? Because I need them encoded as html5 data attribute to be displayed by client side code at later stage. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
