https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki
Splitting this from bug 34594 comment 5:
The use of mw.user.options.get in the code below should indicate whether the user has or has not enabled the option in its preferences[2]:
console.log('$.isEmpty(mw.user.options.values)=', $.isEmpty(mw.user.options.values));
console.log(
'usebetatoolbar=' + mw.user.options.get('usebetatoolbar') + ';' + 'showtoolbar=' + mw.user.options.get('showtoolbar')
);
mw.loader.using('user.options', function () {
console.log('using "user.options" > $.isEmpty(mw.user.options.values)=', $.isEmpty(mw.user.options.values)); console.log( 'using "user.options" > ' + 'usebetatoolbar=' + mw.user.options.get('usebetatoolbar') + ';' + 'showtoolbar=' + mw.user.options.get('showtoolbar') );
});
Nonetheless, I've tested it on Portuguese Wikipedia[1], which is currently running MW 1.18wmf1 (r109351), using Google Chrome 17.0.963.56, and the result is inconsistent:
On each of the following cases
- Only "Show edit toolbar (requires JavaScript)" enabled Note: Old toolbar was loaded, as expected
- Only "Enable enhanced editing toolbar" enabled Note: Enhanced toolbar was loaded, DISRESPECTING the user's choice of disabling "Show edit toolbar (requires JavaScript)". This was described on bug 30795, and I believe it justify marking bug 19786 as WORKSFORME.
- Both options enabled Note: Enhanced toolbar was loaded, as expected
- Both options disabled Note: No toolbar was loaded, as expected
the result is always the same:
$.isEmpty(mw.user.options.values)= true
load.php:1usebetatoolbar=null;showtoolbar=null
load.php:1using "user.options" > $.isEmpty(mw.user.options.values)= false
load.php:1using "user.options" > usebetatoolbar=1;showtoolbar=1
So, after the module "user.options" loaded, mw.user.options.get(...) isn't returning any useful information about the user's choices regarding the toolbar.
If I test the same code, and the same combination of preferences on debug mode (adding ?debug=1 to the URL), the resulting log is always the same, but different from the above:
$.isEmpty(mw.user.options.values)= true
load.php:3usebetatoolbar=null;showtoolbar=null
load.php:8using "user.options" > $.isEmpty(mw.user.options.values)= true
load.php:9using "user.options" > usebetatoolbar=null;showtoolbar=null
I don't know if I should report in a separated bug the fact that
mw.loader.using('user.options', function () {/* code */})"
doesn't guarantee that mw.user.options.values will be filled with the user's preference.
But this is certainly also a bug, because currently the /* code */ can't use mw.user.options.get() at all.
[1] https://pt.wikipedia.org/?oldid=29092806
[2] https://pt.wikipedia.org/wiki/Special:Preferences?uselang=en#mw-prefsection-editing
Version: 1.18.x
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=19786