Page MenuHomePhabricator

Allow users to reset skin preferences to default with api action=options
Closed, ResolvedPublic

Description

Api action=options has a documented feature:

If no value is given (not even an equals sign), the option will be reset to its default value

But the query api.php?action=options&change=skin&token= will give "Validation error for 'skin': ", because HTMLRadioField::validate will return false on the given null value and that false is converted to a empty string. When it will return true, the null is passed to User::setOption and than gets it default value, which is okay.

See Also:

Details

Reference
bz63080

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:01 AM
bzimport set Reference to bz63080.
bzimport added a subscriber: Unknown Object (MLST).

When not passed a value to set the option to, ApiOptions should either skip the validation attempt (relying on $user->setOption to handle null properly) or should fetch the default itself from User::getDefaultOption.

The former seems slightly easier, while the latter seems slightly cleaner. I don't see a whole lot of reason to prefer either way.

Change 123367 had a related patch set uploaded by Konarak:
Handle defaults for api action=options

https://gerrit.wikimedia.org/r/123367

He7d3r renamed this task from cannot reset skin preferences to default with api action=options to Allow users to reset skin preferences to default with api action=options.Dec 22 2015, 1:24 PM
He7d3r updated the task description. (Show Details)
He7d3r set Security to None.

Change 445759 had a related patch set uploaded (by Bartosz Dziewoński; owner: MaxSem):
[mediawiki/core@master] ApiOptions: fix resetting some preferences to default

https://gerrit.wikimedia.org/r/445759

Change 445759 had a related patch set uploaded (by Bartosz Dziewoński; owner: MaxSem):
[mediawiki/core@master] ApiOptions: fix resetting some preferences to default

https://gerrit.wikimedia.org/r/445759