Page MenuHomePhabricator

Audit callers of UserOptionsLookup::getDefaultOption(s) to ensure they will work with conditional options defaults
Closed, ResolvedPublic2 Estimated Story Points

Description

As part of implementing T321527: Support conditional defaults for user properties, the Growth team is changing the signature of UserOptionsLookup::getDefaultOptions and UserOptionsLookup::getDefaultOption to include an optional $user parameter. If this parameter is included, UserOptionsLookup calls ConditionalDefaultsLookup and takes any possible conditional default values into account. If the parameter is omitted (or explicitly passed as null), only the sitewide defaults are returned.

Within this task, all callers of UserOptionsLookup::getDefaultOptions and UserOptionsLookup::getDefaultOption should be audited. The $user parameter should be either set to the current user or optionally, the decision to fetch sitewide defaults (disregarding any conditional defaults) should be made explicit by explicitly setting $user = null.

Until https://gerrit.wikimedia.org/r/c/978537 gets merged, all patches uploaded as part of this task need to be depending on the core patch for the changes to be meaningful.

List of callers

See CodeSearch (note some instances of getDefaultOption are unrelated to the UserOptionsLookup class).

Wikimedia deployed
External
  • Extension:TEI
  • miraheze/ManageWiki
  • oetterer/BootstrapComponents

Related Objects

Event Timeline

Restricted Application added subscribers: Reception123, Aklapper. · View Herald Transcript

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

[mediawiki/extensions/BetaFeatures@master] Support conditional user defaults

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

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

[mediawiki/extensions/CentralAuth@master] Support conditional user defaults

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

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

[mediawiki/extensions/GrowthExperiments@master] Support conditional user defaults

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

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

[mediawiki/extensions/MultimediaViewer@master] Support conditional user defaults

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

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

[mediawiki/extensions/WikimediaEvents@master] Support conditional user defaults

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

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

[mediawiki/skins/Vector@master] Support conditional user defaults

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

Urbanecm_WMF triaged this task as High priority.
Urbanecm_WMF set the point value for this task to 2.

Extension:LiquidThreads (no changes required)

I think that one needs to look up the user based on wl_user and apply conditional preferences. And since this is batch processing, it probably needs to batch the user lookup (which might or might not help depending on the condition, but it will for the one condition we currently have).

The other thing that would technically break is GenderCache, but then a conditional default for gender doesn't make any sense.

Extension:MediaSearch (no changes required)

This does need a change - it's the same as SpecialSearch which does get updated in the core patch.

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

[mediawiki/extensions/MediaSearch@master] Support conditional user defaults

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

Extension:LiquidThreads (no changes required)

I think that one needs to look up the user based on wl_user and apply conditional preferences. And since this is batch processing, it probably needs to batch the user lookup (which might or might not help depending on the condition, but it will for the one condition we currently have).

Technically, yes. However, the current code (for both branches) depends on the default to be (unconditionally) false (setting it to true would break the current code as well, even without conditional defaults). If the default was true, NewMessages:: getRowsObject (or more precisely, its usage in getNotifyUsers) would break, regardless of conditional defaults. This is why I listed it as "no changes required", because the breakage happens either way.

Granted, if the preference was hidden, the breakage would only happen for conditional defaults only, but dunno whether it makes sense to fix it half-way. I'll fill a task to refactor the code to work irrespective of site configuration. I probably should've clarified that somewhere :).

The other thing that would technically break is GenderCache, but then a conditional default for gender doesn't make any sense.

Yeah, agreed. Conceptually, fixing this might make sense as well though. Will fill a pro-forma task as well.

Extension:MediaSearch (no changes required)

This does need a change - it's the same as SpecialSearch which does get updated in the core patch.

Good catch! Fixed, see https://gerrit.wikimedia.org/r/988506.

Change 987722 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Support conditional user defaults

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

Change 988506 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Support conditional user defaults

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

Change 987750 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Support conditional user defaults

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

Change 987749 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Support conditional user defaults

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

Change 987721 merged by jenkins-bot:

[mediawiki/extensions/BetaFeatures@master] Support conditional user defaults

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

Change 987725 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Support conditional user defaults

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

Change 987723 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Support conditional user defaults

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

I think that one needs to look up the user based on wl_user and apply conditional preferences. And since this is batch processing, it probably needs to batch the user lookup (which might or might not help depending on the condition, but it will for the one condition we currently have).

Technically, yes. However, the current code (for both branches) depends on the default to be (unconditionally) false (setting it to true would break the current code as well, even without conditional defaults). If the default was true, NewMessages:: getRowsObject (or more precisely, its usage in getNotifyUsers) would break, regardless of conditional defaults. This is why I listed it as "no changes required", because the breakage happens either way.

Fair point. It could just do a getOptions check instead of a direct database check, but fixing already broken code is beyond the scope of this task and probably not worth the effort anyway given how little that extension is used.

The other thing that would technically break is GenderCache, but then a conditional default for gender doesn't make any sense.

Yeah, agreed. Conceptually, fixing this might make sense as well though. Will fill a pro-forma task as well.

It cannot depend on the current user (since it's a sitewide cache) and needs to support batch loading users, which IMO makes fixing it way more effort than what's worth given the implausibility of the use case.

Filled T354596 and T354598 for good measure; I'll also list those cases as limitations in the in-progress docs page. Considering all of the other extensions have a patch merged (or genuinely do not need any changes), this task can now be resolved.