Page MenuHomePhabricator

ParserFunctions only work in global parser
Closed, DeclinedPublic

Description

Author: james.robinson

Description:
I added a comment here: http://meta.wikimedia.org/wiki/Talk:ParserFunctions

but thought a patch that folks could review would be helpful.

In summary, the new MagicWords added by the extension are only available to the
global parser: $GLOBALS['wgParser']

In several extensions i use my own local parser so as to not muck up the global
variables which can have nasty side effects; however, parsing an article with a
local parser basically fails since the ParserFunctions MagicWords are not available.


Version: unspecified
Severity: normal
URL: http://about.extension.org/wiki/

Details

Reference
bz7051

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:24 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz7051.
bzimport added a subscriber: Unknown Object (MLST).

james.robinson wrote:

patch to allow ParserFunctions to work with other parser objects

Attached:

You can clone $wgParser to produce an independent local parser with all the extensions
registered, this has the advantage of avoiding setup overhead.

james.robinson wrote:

That did not occur to me. I'll test that out. Thank you kindly.

Your suggestion is still a good one, and we may well implement something similar to it. My
only reservation is that extension registration is best done in firstCallInit() rather than
clearState(). That would require adding a new hook. Hook-based registration is better than
what we have now, but ideally I would like to have the registered extension list cached as
a whole, rather than initialised by running code from every extension on every web request.

robchur wrote:

Reopening; no indication of how this was fixed, and I see no relevant commits.

(In reply to comment #5)

Reopening; no indication of how this was fixed, and I see no relevant commits.

Comment #2 'fixes' this.