[Mediawiki-l] Extension help: why is text appearing twice?

Rob Church robchur at gmail.com
Tue Aug 28 21:44:08 UTC 2007


On 28/08/07, Daniel Barrett <danb at vistaprint.com> wrote:
> I'm having a mysterious problem with a custom extension (in MW 1.10.1)
> that seems to be running twice instead of once. Here is a minimal
> example:
>
>                 <?php
>                 $wgHooks['ParserBeforeTidy'][] = 'Problem';
>                 function Problem(&$parser, &$text) {
>                   $text = "$text abc";
>                 }
>                 ?>
>
> This should simply append the string "abc" to the end of the article
> text, and it does.  However, it also prints "abc" inside the footer!
> The footer append is happening here (notice the "abc"):
>
>                 <li id="viewcount"><p>This page has been accessed 2,125
> times.</p> abc</li>
>
> Why does this second append happen, and how can it be prevented?

The hook's called once per parse run. We parse more than just article
text on views, hence the hook's called multiple times.

You need to find a more appropriate hook to use if you just want to
append to page views.


Rob Church



More information about the MediaWiki-l mailing list