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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T54479, the corresponding Phabricator task for complete and up-to-date bug report information.
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)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: javascript
Depends on:
Blocks:
  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: ---


Attachments

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

https://gerrit.wikimedia.org/r/113307
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.


Navigation
Links