Topic on Project:Support desk

Possible (weird) bug with tags??

4
Mfort123 (talkcontribs)

My setup:

Mediawiki: 1.23.5 PHP: 5.5.21 MYSQL:5.6.23

I'm seeing a weird bug with some custom tags that rely on parsing wikitext. The following example is a simplification (I'm just parsing a div tag) to highlight that the problem is related to the use of the parser:

class myClass{

public static function ExtensionSetupParserFunction( Parser$parser ) {
 
$parser->setHook( 'mywiki-tag', 'self::ExtensionRenderParserFunction');

return true;

}

public static function ExtensionRenderParserFunction($input, array $args, Parser $parser, PPFrame $frame ) {

#simple div tag
$wikiText='<div>'.$input.'</div>'; 

#let's parse it
$newParser=new Parser();
$res=$newParser->parse($wikiText,$parser->getTitle(),$parser->getOptions())->getText();

#return 
return $res; 
}

#end of class

}

#Now register the tag:

$wgHooks['ParserFirstCallInit'][] = 'myClass::ExtensionSetupParserFunction';

Now let's use this tag:

<mywiki-tag>input</mywiki-tag>a
<mywiki-tag>input</mywiki-tag> a

The html corresponding to the first line:

<div>input</div> a

The second line has an extra pre tag around 'a':

<div>input</div><pre> a</pre> .

In the rendering function, if we remove the div tags and just parse the input directly then everything is OK. Any idea what's going on here?

Florianschmidtwelzow (talkcontribs)

Another question would be: What is the reason to do that? Why you would parse a text inside a parser tag? You shouldn't need to do this, maybe you could explain a little bit further, what you really want to do :)

76.68.156.239 (talkcontribs)

For my purpose, the tags are better than templates or a parser function. Anyhow, can anyone explain the behavior that I'm getting with even the simplest of tags (as above). It appears that there is a bug.

Florianschmidtwelzow (talkcontribs)

Sorry, than i don't know, why that happens, sorry.

Reply to "Possible (weird) bug with tags??"