Page MenuHomePhabricator

wfMsgExt() with 'parse' or 'parseinline' crashes when $wgTitle == null
Closed, DeclinedPublic

Description

When wfMsgExt() is called with the 'parse' or 'parseinline' option while $wgTitle is null (say, from a parser hook while parsing stuff in the API), a fatal error occurs. Either the dependency on $wgTitle should be removed, or wfMsgExt() should handle this case gracefully.


Version: 1.15.x
Severity: enhancement

Details

Reference
bz18257

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:37 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz18257.

cf. bug 17329.
IMHO the only way to solve both bugs properly is to write an own member function of $wgParser (->msgExt)? and use it from within the parser instead relying on global functions which in turn rely on $wgTitle.

(In reply to comment #1)

cf. bug 17329.
IMHO the only way to solve both bugs properly is to write an own member
function of $wgParser (->msgExt)? and use it from within the parser instead
relying on global functions which in turn rely on $wgTitle.

I think wfMsgExt() using e.g. "Msg" as a dummy title (I seem to recall it did that once) would be good enough. Hardly anyone relies on {{PAGENAME}}-like stuff in such messages anyway.

(In reply to comment #2)

I think wfMsgExt() using e.g. "Msg" as a dummy title (I seem to recall it did
that once) would be good enough. Hardly anyone relies on {{PAGENAME}}-like
stuff in such messages anyway.

Not a bad idea. How many places are we working around this so far? It would make far more sense to just throw a dummy title in there.

(In reply to comment #2)

I think wfMsgExt() using e.g. "Msg" as a dummy title (I seem to recall it did
that once) would be good enough. Hardly anyone relies on {{PAGENAME}}-like
stuff in such messages anyway.

Well, that would be another dirty hack, wouldn't it? There could be a {{PAGENAME}} in nearly any customized message. See for example bug 17442, where apparently this behavior caused a lot of confusion.

(In reply to comment #3)

(In reply to comment #2)

I think wfMsgExt() using e.g. "Msg" as a dummy title (I seem to recall it did
that once) would be good enough. Hardly anyone relies on {{PAGENAME}}-like
stuff in such messages anyway.

Not a bad idea. How many places are we working around this so far? It would
make far more sense to just throw a dummy title in there.

Did this in r50132, but of course it's just a temporary workaround. Code unnecessarily depending on $wgTitle should die.

Deprecated function, no comments since 2009, so resolving wontfix.