On 24/03/11 07:06, Stephan Gambke wrote:
I work on an extension that used to call parse()
directly. Then after
some advice from mw developers this was changed to a call to
recursiveTagParse because "parse should not be called directly".
Only problem is, the method that used to call parse() is used to
populate a Special page, so parse() is never called in the first place,
right? This means all the things parse() does in addition to
recursiveTagParse have to be copied over. So, what exactly makes it so
inadvisable to call parse()?
recursiveTagParse() is the function to use from a tag hook or other
parser hook, to parse text when a parse operation is already in
progress on the same Parser object. It should not be used when a parse
operation is not in progress. Its output is actually half-parsed, with
placeholders for tag hooks and links.
parse() is the function to use when a parse operation is not in
progress, such as in a special page. It should not be used from a hook
into a parse operation, unless a separate Parser object is
constructed. This is because it destroys the state of the Parser
object on which it is called.
Includable special pages have an execute() function which can be
called from either context, so to parse text within them, it's
necessary to check $this->mIncluding to determine the correct function
to use. I don't recommend using includable special pages in new
extensions.
Hope that helps.
-- Tim Starling