Page MenuHomePhabricator

Add setting to hide a list of preferences
Closed, ResolvedPublic

Description

In Preferences users are asked their gender.

Even though they can choose gender-unknown, we administrators would be
more comfortable if there was a configuration choice for our wikis so
such questions never appear. At least a hook.

Just let our wiki be all gender-unknown.

Not only would my http://transgender-taiwan.org/ benefit, but I'm sure
many other wikis would opt for such a choice.


Version: 1.16.x
Severity: enhancement

Details

Reference
bz18761

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:36 PM
bzimport set Reference to bz18761.
bzimport added a subscriber: Unknown Object (MLST).

I'm not convinced this is needed, but if somebody wants to add it I do not oppose.

Per Niklas, this isn't really needed, so marking as WONTFIX.

However, this can be easily accomplished for any single preference a wiki admin wants to hide. In LocalSettings:

$wgHooks['GetPreferences'][] = 'hookfunc';

function hookfunc( &$user, &$prefs ) {

if ( isset( $prefs['gender'] ) ) {
   unset( $prefs['gender'] );
}
return true;

}

And 'gender' can be replaced with any of the preference keys.

Eh, we make the real name field optional. I don't see a reason to make gender non-optional, esp. for single wiki installations that are all English (or some other language where gender is completely unimportant). Recommend re-opening this and adding a configuration option.

And if the real name question had come up now, I would say the same thing. It's much easier for wiki admins to just make an individual hook function to control these, rather than add a new variable every time 1 person decides they don't want to show a particular preference.

Instead of the relatively ugly hook, maybe $wgDisabledPreferences or something in that spirit would be a better (at least cleaner / more usable) idea.

Or just "add another column" or two to $wgDefaultUserOptions.
(Make into a list of lists).
Then several properties could be added...

Ah yes, a clever change to DefaultSettings.php would be all that is
needed. Older scripts would still get the scalar value, whilst scripts
'in the know' could access the remaining properties. It is getting hot
in here. I'll adjust the air conditioner. Be back soon.

I'm re-opening this for now. WONTFIX is "we're never, ever gonna do this so stop asking." Comment 5 indicates one way to have this functionality. Comment 7 indicates possibly updating documentation somewhere to resolve this. Either way, I'd like to give it a bit more time to sit and stew.

bugzilla wrote:

Changes to Preferences.php and DefaultSettings.php against trunk@50475

Not yet tested, but it's a similar pattern to what's setup for wgAllowRealName. I suppose I'll refire my VM at some point this week if nobody else closes this bug.

attachment gitdiff ignored as obsolete

bugzilla wrote:

Patch was tested and does work.

Created attachment 6126
Implement $wgHiddenPrefs

Here's a patch to make an array of prefs to hide from users. Still not sure if it's worth committing.

Obsoleting the previous patch because yet-another-global to change a single preference is a bad idea, IMHO, per my comment 4.

Attached:

ayg wrote:

$wgHiddenPrefs sounds like a good idea. Generally I don't have a problem with adding more config variables, within the bounds of sanity. The overhead is pretty minimal, and usually when doing support we ask the person to paste their LocalSettings anyway. It's reasonable that some sites won't want to ask users their genders, and this is a nice general way to handle that.

Updated summary. From "Allow not asking users their gender" to "Add setting to hide a list of preferences"

OK, split off Bug 18841 to only ask gender if it will indeed be used, etc.

I recommend committing the patch for release in 1.16, but note that $wgAllowRealName needs to stay in DefaultSettings.php marked as deprecated, to avoid a register_globals vulnerability. There should be no isset().

To say it isn't needed, when Jidanni has an example of a wiki about transgender issues in a language lacking grammatical genders, is a bit bizarre. The question would cause offence regardless of how long the explanation is. I would suggest that Jidanni patches this change in if he needs to run 1.15.

Looks good to me; as Tim notes a default setting of $wgAllowRealName needs to be retained. Always set your globals before use. :)

Applied modified patch in r50782

Created attachment 6137
Better comment

Attached:

ayg wrote:

Comment improved in r50822.

$wgAllowRealName was not removed everywhere, so I replaced them by $wgHiddenPrefs, and I made $wgAllowUserSkin obsolete, because it's also replaced by $wgHiddenPrefs. (r50782)