Steps to reproduce
- Login and visit https://en.m.wikipedia.beta.wmflabs.org/w/index.php?title=Special:MobileOptions on the MinervaNeue mobile site.
- Enable AMC.
- Visit https://en.m.wikipedia.beta.wmflabs.org/wiki/Special:Preferences.
- Toggle "Default to newcomer homepage from username link in personal tools" and save.
- Special:MobileOptions persist.
- All Special:MobileOptions are reverted.
- Browser version: Chromium v75.0.3770.90
- OS version: Ubuntu v19.04
- Device model: Desktop
- Device language: English
- Does this affect the AMC opt-in and opt-out rates?
The problem is that the amc user preference registration is done incorrectly. It uses only UserGetDefaultOptions hook to set a default user option value, but it does not use register option via GetPreferences hook.
Most probably GetPreferences hook wasn't handled because we didn't want to show AMC mode on Special:Preferences page. But we need to register it with type=api so option is registered, but not visible on the Special:Preferences page.
What currently happens:
Everything starts in DefaultPreferencesFactory::saveFormData()
- DefaultPreferencesFactory::saveFormData() calls user->resetOptions( 'unused', $form->getContext() );
- User::resetOptions loads all user options and uses options definitions (loaded via GetPreferences hook)
- if option definition does not exist it's marked as 'unused' and later removed
Important note: AMC is not the only option that is removed on the Special:Preferences save. MediaWiki core also removes:
- mfMode -- Beta Mode works only because we set up the cookie. The beta-opt-out graph might be broken.
Please fix also those.