Page MenuHomePhabricator

Allow features to be registered with unnamed requirements
Open, MediumPublic

Description

Quoting @polishdeveloper:

[The] existing solution is pretty verbose, creating single Feature requires us to define name, config variable, group.

The most basic (and likely most common) usecase for the developer will be to create a feature that has one or more requirements that are specific to that feature. Vector's Feature Manager currently requires that requirements be created separately to features, e.g.

$featureManager->registerSimpleRequirement( 'foo_enabled', $config->get( 'wgFooEnabled' ) );
$featureManager->registerRequirement( new LatestSkinVersionRequirement() );
$featureManager->registerFeature( 'FooFeature', [
  'foo_enabled',
  LatestSkinVersionRequirement::class
] );

It should be possible to write the above using on function call:

$featureManager->registerFeature(  'FooFeature', [
  $config->get( 'wgFooEnabled' ),
  new LatestSkinVersionRequirement(),
] );

Event Timeline

ovasileva triaged this task as Medium priority.May 4 2020, 11:25 AM
ovasileva added a project: Readers-Web-Backlog.
ovasileva moved this task from Incoming to Triaged but Future on the Readers-Web-Backlog board.

Change 626359 had a related patch set uploaded (by Phuedx; owner: Phuedx):
[mediawiki/skins/Vector@master] featureManager: Register requirements implicitly

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

Change 649402 had a related patch set uploaded (by Jdlrobson; owner: DannyS712):
[mediawiki/core@master] Add Skin::supportsFeature

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

Change 649402 abandoned by Jdlrobson:
[mediawiki/core@master] Add Skin::supportsFeature

Reason:
Let's discuss further on ticket. Can't review unless we agree on the approach first

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

Change 626359 abandoned by Phuedx:

[mediawiki/skins/Vector@master] featureManager: Register requirements implicitly

Reason:

This isn't The Fix™. When I get a little down time (next Monday is the most likely), then I'll create a task detail The Fix™.

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