Page MenuHomePhabricator

Accept mw.title object as the title argument of frame:expandTemplate()
Closed, ResolvedPublic

Description

It even makes more sense to accept a title object than a string.


Version: unspecified
Severity: normal

Details

Reference
bz47601

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:33 AM
bzimport set Reference to bz47601.
bzimport added a subscriber: Unknown Object (MLST).

frame:expandTemplate doesn't validate the type of its argument, and just calls tostring() on it. Since tostring( titleObj ) returns the page title, frame:expandTemplate already does accept a title object.

The only caveat is that you can't pass in a namespace-0 title object in this way, since it will be stringified without a leading colon so then frame:expandTemplate will look for it in the Template namespace instead of namespace 0.

(In reply to comment #1)

The only caveat is that you can't pass in a namespace-0 title object in this
way, since it will be stringified without a leading colon so then
frame:expandTemplate will look for it in the Template namespace instead of
namespace 0.

This is the reason I filed this bug.

(In reply to comment #2)

(In reply to comment #1)

The only caveat is that you can't pass in a namespace-0 title object in this
way, since it will be stringified without a leading colon so then
frame:expandTemplate will look for it in the Template namespace instead of
namespace 0.

This is the reason I filed this bug.

You should have stated that in your original description.

This should be easy enough with the same sort of check used in mw.message's title() method, just prepend the necessary colon if the passed value is a table with .namespace == 0.

Change 125207 had a related patch set uploaded by Happy5214:
Accept mw.title object as the title argument of frame:expandTemplate()

https://gerrit.wikimedia.org/r/125207

Change 125207 merged by jenkins-bot:
Accept mw.title object as the title argument of frame:expandTemplate()

https://gerrit.wikimedia.org/r/125207

The change should be deployed to WMF wikis with 1.24wmf1, see https://www.mediawiki.org/wiki/MediaWiki_1.24/Roadmap for the schedule.