Last modified: 2014-09-05 22:44:44 UTC
As the preferred way to access the wg* variables in JavaScript is to use mw.config.get()/.set(), accessing them as globals (i.e. as members of window) should show deprecation notices in debug mode, just like it is done for the functions from wikibits.js.
mw.config.get('wg*') is currently basically a wrapper for window.wg*. To make such deprecation notices possible we'd have to duplicate the values, which could cause them to get out-of-sync if something modified them after page load.
Hm, how would deprecation actually work? Can we add getters on the window object?
(In reply to comment #1) > mw.config.get('wg*') is currently basically a wrapper for window.wg*. To make > such deprecation notices possible we'd have to duplicate the values, which > could cause them to get out-of-sync if something modified them after page > load. Is this an actual issue? Once they are set, they shouldn't be changed anyway. So using a new object for mw.config.values instead of window and copying the variables over when they are set the first time using mw.log.deprecate shouldn't break more than replacing some of the wikibits.js functions with $.noop will break. (In reply to comment #2) > Hm, how would deprecation actually work? Can we add getters on the window > object? Yes, if you don't believe it, have a look at wikibits.js.
(In reply to comment #3) > (In reply to comment #1) > > mw.config.get('wg*') is currently basically a wrapper for window.wg*. To make > > such deprecation notices possible we'd have to duplicate the values, which > > could cause them to get out-of-sync if something modified them after page > > load. > > Is this an actual issue? Once they are set, they shouldn't be changed anyway. > So using a new object for mw.config.values instead of window and copying the > variables over when they are set the first time using mw.log.deprecate > shouldn't break more than replacing some of the wikibits.js functions with > $.noop will break. Apparently VisualEditor sets one, see bug 56532.
I just tried, and found that mw.log.deprecate can be called multiple times for the same variable without any problems. So mw.config.set could just call it, and whenever a wg* variable is changed via mw.config.set the global value would be updated, too. Only the other way round wouldn't work (or require some extra code instead of mw.log.deprecate).
mw.log.deprecate warnings are now visible when not in debug mode too.
Change 133162 had a related patch set uploaded by Gerrit Patch Uploader: Show deprecation notices when accessing wg* JavaScript globals https://gerrit.wikimedia.org/r/133162