A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

DefaultUserOptions: List of values

Osnard

Is it possible to have an array as an user option? For example a list of namespaces or categories. Using

"DefaultUserOptions": {
	"my-ext-enabled-namespaces": [ 0 ],

in extension.json causes an issue in User::getOptions [1]. The only examples that I’ve found [2][3] suggest that a list can only be saved as delimiter-seperated-string. In that case I would either need to deserialize it in the place I use it, or bind to UserGetOptions hook. Any suggestions on this? Or best practices?

[1] https://github.com/wikimedia/mediawiki/blob/master/includes/user/User.php#L2938
[2] https://github.com/wikimedia/mediawiki/blob/a79d012e1c40dbeeb55a90b8099fea4aa9b1270b/includes/user/User.php#L5332-L5336
[3] https://github.com/wikimedia/mediawiki-extensions-Translate/blob/7bef0ed3ec963baf391bece71f51c11afe0160a3/translationaids/InOtherLanguagesAid.php#L57-L59

Tgr

User options are stored in a string column with no intelligent conversion. Expect anything that’s not a string (boolean values etc) to get corrupted :confused:

T54542 is a related task.