Page MenuHomePhabricator

BetaFeatures not strictly compatible with PrefUpdate instrumentation or vice versa
Open, LowPublic

Description

NOTE: This is less of an issue now that we only track the enrollment of two beta features using the PrefUpdate instrumentation (see https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikimediaEvents/+/refs/heads/master/includes/PrefUpdateInstrumentation.php#78 and L79).

The BetaFeatures extension stores beta feature enrolment and auto-enrolment as a user preference. WMF is interested in changes to certain preferences and tracks them using the PrefUpdate instrumentation. When a tracked preference is updated, a PrefUpdate event is created and logged.

The PrefUpdate instrument determines whether the preference's current value is the same as the preference's default value and sets the PrefUpdate event's isDefault property accordingly. Currently, the default value for those preferences that store beta feature enrolment is null and so all PrefUpdate events are logged with isDefault = false.

The default value of a user preference is controlled by:

  • $wgDefaultUserOptions
  • The current wiki's content language
  • $wgNamespacesToBeSearchedDefault
  • $wgDefaultSkin
  • The UserGetDefaultOptions hook
Possible Fix

Implement a UserGetDefaultOptions hook handler to register a default value of false for every beta feature:

BetaFeatures/includes/BetaFeaturesHooks.php
public static function onUserGetDefaultOptions( &$defaultOptions ) {
  $betaFeatures = \MediaWikiServices::getInstance()
    ->getMainConfig()
    ->get( 'BetaFeatures' );

  $defaultOptions += array_fill_keys(
    array_keys( $betaFeatures ),
    false
  );
}
Questions
  • Should the default value be false if the user has enabled auto-enrol?

Event Timeline

Per the note in the description.

Change 724519 had a related patch set uploaded (by Krinkle; author: Umherirrender):

[mediawiki/extensions/BetaFeatures@master] Set DefaultUserOptions

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

Change 724519 merged by jenkins-bot:

[mediawiki/extensions/BetaFeatures@master] Set DefaultUserOptions

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