Page MenuHomePhabricator

Inconsistent local value set when submitting Special:Preferences without local-exception set
Open, Needs TriagePublicBUG REPORT

Description

What is the problem?

If I have a local-exception for a global user option, if I unset and submit the form, the local value of that option remains set in the database.

If I submit the form a second time, the local value of the same option is removed (i.e. it is reset to default).

It feels to me like the outcome of both of those actions should be the same. Either the value should be removed the first time I submit, or the value should be maintained the second time I submit.

This affects a number of different user options, which I will list below.

Steps to reproduce problem
  1. Go to Special:GlobalPreferences
  2. Set "Allow other users to email me" as global and submit
  3. Go to Special:Preferences
  4. Check the local-exception checkbox for "Allow other users to email me", uncheck its local value and submit
    set_local_exception.png (77×447 px, 7 KB)
  5. Check the database (you can use this SQL query: SELECT user_properties.* FROM user_properties INNER JOIN actor ON actor_name="<username>" AND up_user=actor_user WHERE up_property="disablemail";)
    step5_database.png (92×330 px, 1 KB)
  6. In Special:Preferences, uncheck the local-exception for "Allow other users to email me" and submit again
    unset_local_exception.png (77×456 px, 7 KB)
  7. Check the database
    step7_database.png (90×328 px, 2 KB)
  8. Submit the Special:Preferences form again (you might need to change another user preference in order to submit)
    unset_local_exception_second_submit.png (69×466 px, 7 KB)
  9. Check the database
    step9_database.png (34×199 px, 1 KB)
  10. Go to Special:GlobalPreferences and remove the global setting for "Allow other users to email me"
  11. Go to Special:Preferences and look at the value of "Allow other users to email me"
    final_outcome.png (48×396 px, 2 KB)

Observed behavior: The checkbox is checked, even though the last time I explicitly set that value I set it to unchecked. The value in the database is the same in steps 5 and 7 (the value is 1), it is different in step 9 (the value is not set).

Expected behavior: The bug for me is that I am submitting the Special:Preferences form twice without changing the value of "Allow other users to email me", but it is being set to a different value each time in the database.
I am not sure exactly what the expected behaviour should be (it might be a PM/design decision), but I suggest it should be one of either:

  • a) The value of disablemail in the database in steps 5, 7 and 9 should be the same, or
  • b) The value of disablemail in the database in steps 7 and 9 should be the same
Environment

Browser: Chromium 87, Firefox 78
Wiki(s): https://en.wikipedia.beta.wmflabs.org MediaWiki 1.38.0-alpha (73f4932) 12:09, 1 December 2021. GlobalPreferences 0.1.2 (e9ea9af) 05:41, 1 December 2021.

User options affected

On enwiki beta, I set every user option (which is a checkbox type, I didn't test other kinds of user options) to be global. I repeated the repro steps above for all the options. The options I think are affected include (but not limited to):

  • centralnotice-display-campaign-type-advocacy
  • centralnotice-display-campaign-type-article-writing
  • centralnotice-display-campaign-type-event
  • centralnotice-display-campaign-type-fundraising
  • centralnotice-display-campaign-type-governance
  • centralnotice-display-campaign-type-photography
  • disablemail
  • discussiontools-newtopictool
  • discussiontools-replytool
  • echo-cross-wiki-notifications
  • email-allow-new-users
  • flow-visualeditor
  • hidecategorization
  • multimediaviewer-enable
  • popups-reference-previews
  • previewontop
  • skin-responsive
  • twocolconflict-enabled
  • usebetatoolbar
  • useeditwarning
  • watchcreations
  • watchlisthidecategorization
  • watchuploads
  • wikilove-enabled

(note that I only tested this on enwiki beta, and each wiki has a different set of user options. There might be more user options affected by this bug.)

Event Timeline

This was fixed per change 737702 which can keep the old local values, but restored due to T298614.
I finally convinced myself that saving global values to local database positively is good, since we can provide a better experience without changing a lot of behavior after the user deglobalized some preferences.

Change 753952 had a related patch set uploaded (by Func; author: Func):

[mediawiki/extensions/GlobalPreferences@master] Override local preferences with global values in database positively

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