[Mediawiki-api] adding action=getmsg

Brad Jorsch b-jorsch at northwestern.edu
Tue May 5 17:21:24 UTC 2009


On Tue, May 05, 2009 at 09:10:16AM -0700, Michael Dale wrote:
> Could we add in an action get message to the api or add some 
> functionality to meta=allmessages ?
> 
> Really need to be able to:
> A) send in parameterized replace values per msg key
> B) get the html rendered / parsed result (rather than the wikitext)   
> 
> Security wise the parameterized replace values should be treated as 
> wikitext and go through the wiki-text-parser before rendered back out to 
> the browser.

I'm not sure how feasable that would actually be, as the messages are
not all handled the same way. In fact, as far as I know there isn't even
any generic way to tell how any particular message is handled besides
"read the source". It all depends on how exactly the message is used in
the code that actually makes use of it.

Among other possibilities, the message could be treated as plain text,
as raw HTML, as fully-parsed wikitext (action=parse), or as
preprocessed-only wikitext (similar to if not the same as
action=expandtemplates); see the various wfMsg* functions. Substitution
of the parameters could be done before or after the message itself is
processed, and the individual parameters could themselves have been
processed in any manner before being passed to wfMsgWhatever.

And then the output could potentially be run through the parser again
before actually making it to the browser.

> Otherwise we have to do quite a few calls to generate a msg text that 
> has a parametrized wiki-text-value.

For most cases, you should only need one or two: one to fetch the
message, and possibly one to process it (either before or after
substituting the parameters). A third call to action=parse might be
needed if it's one of those "preprocess, substitute, then parse"
messages mentioned above and you're going all the way to HTML output.

Of course, depending on the message you might need earlier calls to
process the individual parameters before substitution, if you can't
figure out the final parameter content client-side.

Do you have an example of a message that requires quite a few calls?



More information about the Mediawiki-api mailing list