MediaWiki extension CommunityConfiguration

Clone this repo:
  1. 6991aab Localisation updates from https://translatewiki.net. by Translation updater bot · 34 hours ago master wmf/branch_cut_pretest
  2. 4ce4fb0 Localisation updates from https://translatewiki.net. by Translation updater bot · 2 days ago
  3. 73b506a Merge "CommonsFileControl: use config variable for the commons api url" by jenkins-bot · 4 days ago wmf/1.43.0-wmf.25
  4. e81a714 Replace <tt> in messages with <code> by Amir E. Aharoni · 4 days ago
  5. e40a7a0 CommonsFileControl: use config variable for the commons api url by Sergio Gimeno · 4 weeks ago

Community configuration 2.0: Backend extension

This extension is a part of the Community configuration 2.0 project of the Wikimedia Foundation's Growth team. It backs Community configuration itself and is accompanied by the CommunityConfigurationExample as an example usage of Community configuration in a feature.

Setting up locally

An end to end setup of Community configuration depends on three components:

  • This extension, CommunityConfiguration
  • The example usage in CommunityConfigurationExample

To set up Community configuration 2.0, please follow those instructions:

# clone the necessary extensions
core $ git clone https://gitlab.wikimedia.org/repos/growth/community-configuration-example extensions/CommunityConfigurationExample
core $ git clone https://gitlab.wikimedia.org/repos/growth/community-configuration extensions/CommunityConfiguration
# enable extensions in LocalSettings.php
core $ echo "wfLoadExtensions( ['CommunityConfiguration', 'CommunityConfigurationExample' ] );" >> LocalSettings.php

Once done, you should be able to access CommunityConfiguration from Special:CommunityConfigurationExample. Interacting with the Community configuration interface should be also working:

core $ php maintenance/run.php shell
> $config = \MediaWiki\MediaWikiServices::getInstance()->get('CommunityConfiguration.ProviderFactory')->newProvider('static-example')->loadValidConfiguration()
= StatusValue {#5739
    +value: [
      "wgFooBar" => 42,
    ],
    +success: [],
    +successCount: 0,
    +failCount: 0,
  }

> $config->isOK()
= true

> $config->getValue()
= [
    "wgFooBar" => 42,
  ]

>

Json validation example

For a given JSON schema defintion, eg: community-configuration-example/src/Schemas/schema_draft-07.json

core $ php maintenance/run.php shell
> $provider = \MediaWiki\MediaWikiServices::getInstance()->get('CommunityConfiguration.ProviderFactory')->newProvider('FooBar');
= MediaWiki\Extension\CommunityConfiguration\Provider\DataConfigurationProvider {#5696}

> $provider->getValidator()->validate( [ 'FooBar' => 1 ] )->isOk();
= false

> $provider->getValidator()->validate( [ 'FooBar' => 1 ] )->getErrors();
= [
    [
      "type" => "error",
      "message" => "communityconfiguration-schema-validation-error",
      "params" => [
        "/FooBar",
        "The data (integer) must match the type: string",
        Opis\JsonSchema\Errors\ValidationError {#6802},
      ],
    ],
  ]

>

Resources