[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wikitech-l
Subject:    Re: [Wikitech-l] How to get the article content?
From:       "Rob Church" <robchur () gmail ! com>
Date:       2007-10-30 13:49:48
Message-ID: e92136380710300649h10376472off272a7b6a06f3d8 () mail ! gmail ! com
[Download RAW message or body]

On 30/10/2007, "Marcus Schäfer" <magggus@gmx.de> wrote:
> I call it within a parser function, like this:

Never, ever, ever refer to $wgArticle, $wgTitle or $wgParser within a
parser hook callback; the first two are not required to exist in order
to parse text - there might not be an actual saved article that
corresponds to the input (if parsing for the UI, for instance), or the
parsing might be taking place within a maintenance script or other
environment which hasn't been initialised for the web script.

Furthermore, use of $wgParser is technically incorrect - you're passed
a reference to the parent Parser object. While this might be a
reference to the same Parser instance as $wgParser (in most cases it
will be), you cannot guarantee that from within your extension.

If you need the Title of the wiki text being processed, then you can
obtain it from the parser, e.g. $parser->getTitle(), but be careful -
it's not necessarily the case that an actual article will exist.

Furthermore, be careful regarding $wgLanguageCode - its purpose
changes during initialisation. If in doubt, call Language::getCode()
[on the $wgLang and $wgContLang objects].


Rob Church
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/wikitech-l

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic