On Tue, Oct 6, 2009 at 4:47 PM, Mark Clements (HappyDog)
<gmane(a)kennel17.co.uk> wrote:
Hi,
I have an extension called BugSquish, which I have been happily using on
MediaWiki 1.6.10 for quite a long time. I am also aware of other people
using it on later versions, but cannot cite specific version numbers where
it is known to work. The code works by performing a regex replace on code
passed into the ParserAfterStrip hook function that I have set up, to strike
out links to bugs that have been marked as fixed.
On MW 1.6 this correctly handles <nowiki> and <pre> tags, in that text
within these tags is not parsed by the extension.
On MW 1.14 and above the code within the <nowiki> tags is parsed and ends up
having the regex applied to it, though it is subsequently rendered as plain
text by the engine (so the page ends up being filled with HTML/CSS
gobbledygook, rendered literally).
I am not sure at which revision this change took place.
First question: Is this a bug or a deliberate change in functionality, or
have I been mis-using the hook all along?
This was changed during the parser rewrite several versions ago. The
restructuring of the parser meant that strip markers are now handled
differently and can't be routed around using that hook anymore.
ParserAfterStrip is essentially a deprecated legacy that now functions
the same way as ParserBeforeStrip.
Second question: Assuming this is not a bug, how
should I rewrite the code
to make it behave as it used to?
I haven't studied you code in detail, but I would suggest that using
the LinkBegin hook (available 1.14+) is probably the right place to
look in the current versions of Mediawiki:
http://www.mediawiki.org/wiki/Manual:Hooks/LinkBegin
This is called whenever an internal / interwiki link is generated and
allows one modify the text / destination, apply CSS styles, and/or
replace the link with something else entirely.
If you are munging external links (rather than internal / interwiki
links), the corresponding hook is LinkerMakeExternalLink.
-Robert Rohde