Page MenuHomePhabricator

userOptions.php cannot be used to change user options from default to a new value
Closed, ResolvedPublic

Description

As part of working on T353225: Echo: Make use of conditional user defaults,. I need to ensure all users who registered in or after May 2013 have an user_properties row for the echo-subscriptions-web-reverted property (and a bunch of others; see the other task for details). Since this is a boolean property, I intend on achieving this goal by temporarily setting $wgDefaultUserOptions['echo-subscriptions-web-reverted'] = 2; (where 2 is an arbitrary value that casts to true in PHP) and then running a script to change the value for all users from 2 (the temporary default) to 1 (the canonical true).

I expected this:

I have no name!@5f2d8572a442:/var/www/html/w$ php maintenance/run.php userOptions --old=2 --new 1 --nowarn --dry 'echo-subscriptions-web-reverted'
I have no name!@5f2d8572a442:/var/www/html/w$

to do the mass change I need. However, executing the script above performs no changes (as it can be seen from the empty output). I examined why is that, and to take the --old parameter into account, the userOptions.php script includes an up_value = OLD_VALUE condition. This does not work when OLD_VALUE is the default one, since that is represented by no rows at all in the database.

This task is to extend userOptions.php capabilities to include changing user options from the default value, to unblock the T353225 migration.

Related Objects

Event Timeline

Change 988659 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/core@master] userOptions: Support --from being the option's default value

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

Change 988659 merged by jenkins-bot:

[mediawiki/core@master] userOptions: Support --old being the option's default value

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

Urbanecm_WMF added a subscriber: Etonkovidova.

@Etonkovidova FYI, I'll be testing this as well while verifying the T353225 deployment plan at the Beta cluster. Moving to QA, as the patch should be available at Beta by now.

Change 990735 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/core@master] UserOptionsManager: Make it possible to set option values to an empty string

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

Change 990735 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/core@master] UserOptionsManager: Make it possible to set option values to an empty string

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

Please ignore, tagged the patch with an incorrect task.