Last modified: 2014-02-14 10:54:50 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 52479 - mw.msg should not return an error message if the message contains '{{SomeTemplate}}'
mw.msg should not return an error message if the message contains '{{SomeTemp...
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: javascript
Depends on:
  Show dependency treegraph
Reported: 2013-08-02 20:18 UTC by Helder
Modified: 2014-02-14 10:54 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Helder 2013-08-02 20:18:54 UTC
If mw.loader.getState( 'mediawiki.jqueryMsg' ) is not 'ready', and I execute the code
mw.messages.set( {
    'some-key': 'SomeText {{SomeTemplate}}.'
} ); 
alert( mw.msg( 'some-key' ) );
I get 'SomeText {{SomeTemplate}}.' as expected.

But if I enable any gadget which loads the module 'mediawiki.jqueryMsg', and run the same code again, the result unexpectedly changes to 'some-key: Unknown operation "sometemplate"'.

It should still be 'SomeText {{SomeTemplate}}.', because there is no magic word called 'SomeTemplate'
Comment 1 Matthew Flaschen 2013-08-03 01:22:45 UTC
Templates are not currently supported in jQueryMsg, just magic words (the code uses the word 'template' to mean magic words).

mw.msg is equivalent to mw.message(...).text()

meaning the 'text' format/operation is being used.

In the PHP parser's text mode, if a template exists, it is expanded into its wikitext.  If it does not exist, it results in [[:Template:SomeTemplate]].

With the way jQueryMsg currently works, even checking if the template existed would require either:

1. Sending extra data down from ResourceLoader
2. Doing an API call from jQueryMsg

Thus, for now I recommend you use:

mw.message( 'some-key' ).plain()

if you want the output 'SomeText {{SomeTemplate}}.' for this kind of thing.

The 'plain' format does not try to expand {{ }} blocks, just $1, $2 replacement.
Comment 2 Matthew Flaschen 2013-08-03 08:26:07 UTC
Undoing my title change
Comment 3 Gerrit Notification Bot 2014-02-14 00:38:44 UTC
Change 113307 had a related patch set uploaded by Bartosz Dziewoński:
mediawiki.jqueryMsg: Don't throw parse errors in the user's face
Comment 4 Bartosz Dziewoński 2014-02-14 00:40:00 UTC
The above patch sorta kinda addresses this by hiding the user-visible error messages.

Note You need to log in before you can comment on or make changes to this bug.