On 1/7/07, Andrew Dunbar <hippytrail(a)gmail.com> wrote:
I want to preprocess the wikitext of articles adding
info found by a database lookup based on the article
name.
The best place for preprocessing is in the parser so
I've hooked ParserBeforeStrip but the parser works
in chunks of wikitext rather than in articles. I've been
able to filter out the chunks which are not part of the
article because $parser->getVariableValue('revisionid')
will return 0 for those.
But long artices can cause more than one chunk of
wikitext to be sent to the parser and since I only
want to add to the top of the article I need to detect
these chunks and ignore them.
Another problem is that I also want to add to the top
of the 'noarticletext' page which is displayed when
the user enters a URL for a page which doesn't exist.
There is currently no hook for this. I've tried adding
one which works for me but there are actually 3
places in the code which can result in this page.
I'm not sure that I need to hook the other two since
they appear to be edge cases.
One final question is on sharing data between my
hooks for ArticleAfterFetchContent and
ParserBeforeStrip. I'm using a global variable but
maybe there's a better way. ArticleAfterFetchContent
seems to be the best place for doing the database
lookup based on the article name to work nice with
the cache.
Andrew Dunbar (hippietrail)
Just a note that the following bugs are relevant:
Bug 8136: Missing hooks: Undelete (restore) + Rollback
Bug 8560: TitleMoveComplete hook cannot detect redirects
Andrew Dunbar (hippietrail)
--
http://linguaphile.sf.net