Extension:BetaFeatures

The BetaFeatures extension allows other MediaWiki extensions to register beta features with the list of user preferences on the wiki. It uses the existing user preferences architecture and a few special pages to accomplish its function.

Installing BetaFeatures
There's a major caveat to the usual installation instructions: BetaFeatures is something other extensions can depend on, and any extensions that do should be loaded _after_ BetaFeatures, in LocalSettings.php. So after you get a copy of BetaFeatures, you should be sure that your require_once calls are in the proper order.

Otherwise, it's a simple extension installation.

You will then need to run update.php, because BetaFeatures installs a new database table for counting the number of people using a particular preference.

Using the new hooks in your extension
Using this extension to support your beta feature is easy. Register a hook of type "GetBetaFeaturePreferences" in your extension's main file - the syntax is almost identical to the GetPreferences hook, with small changes to support the type of preference we need in this case.

Then, you can use the convenience function provided by BetaFeatures to check whether the feature is enabled.

You can also use a normal preference check, but don't check against truthy or falsy values - use the values from the HTMLFeatureField class.

Because the BetaFeatures class should be present everywhere, you could use the convenience function in any hook, special page, or anything else you wanted. Just be aware of potential performance or caching issues you may introduce with those changes.

Advanced usage
Want to see something really cool?

Auto-enroll groups
With this example, we register a preference that's an "auto-enroll" one - if a user checks this, and new features come out that are in a particular group, the user will be automatically enrolled in those features.

Dependency management
Next up, we can actually define dependency management per-feature. To do this we first register the name of a hook that we want to use for this, then we register a hook of that type that checks some dependency, and returns true if it's met or false if not.

You can abuse use this feature to do per-wiki disabling of features, if they're marked as dependent. But that sounds really hacky. You probably shouldn't. I can hear you thinking about it right now, just stop it.

Getting the latest version
The latest work in BetaFeatures relies on some core patches. So, in your core clone, run these commands:

Then, pull the latest master for BetaFeatures from Gerrit.

Once those are done, you have the latest work that User:MarkTraceur has been doing on the project.