Page MenuHomePhabricator

Value types between default user preferences and stored values should match
Closed, DuplicatePublic

Description

MediaWiki core (and same in extensions) sets values in wgDefaultUserOptions using integer literals.

E.g.

$wgDefaultUserOptions = array(
	'minordefault' => 0,
..
	'rows' => 25,
..
$wgDefaultUserOptions['visualeditor-enable'] = 0;
$wgDefaultUserOptions['visualeditor-betatempdisable'] = 0;

When these values are set by users, saved, and roundtripped back, both in PHP (User::getOptions) as well as client-side (mw.user.options) they are strings instead:

minordefault: "1"
rows: "30"

visualeditor-enable: ""
visualeditor-betatempdisable: "1"

Where in PHP string "0" is falsy, in JavaScript it is not. This leads to the counter-intuitive situation where a user preference is either 0, 1, "" or "1". Depending on whether the user modified their preferences from the site defaults.