wikimedia/mediawiki-extensions-Wikibase

View on GitHub
build/federated-properties/templates/LocalSettings.php.j2

Summary

Maintainability
Test Coverage
<?php
$wgServer = '{{ SCHEME }}://{{ SERVER_NAME }}{{ PORT }}';

# Developer mode and debugging
if ( {{ DEV_ERROR_REPORTING }} ) {
    error_reporting( -1 );
    ini_set( 'display_errors', 1 );
    $wgShowExceptionDetails = true;
    $wgDebugDumpSql  = true;
} else {
    ini_set( 'display_errors', 0 );
}

## Database settings
## Environment variables will be substituted in here.
$wgDBserver = "mysql.svc:3306";
$wgDBname = "my_wiki";
$wgDBuser = "wikiuser";
$wgDBpassword = getenv( 'DB_PASS' );

## Logs
## Save these logs inside the container
$wgDebugLogGroups = [
    'resourceloader' => '/var/log/mediawiki/resourceloader.log',
    'exception' => '/var/log/mediawiki/exception.log',
    'error' => '/var/log/mediawiki/error.log',
];

## Site Settings
$wgShellLocale = "en_US.utf8";
$wgLanguageCode = "en";
$wgSitename = "wikibase-{{ PROJECT_NAME }}";
$wgMetaNamespace = "Project";
# Configured web paths & short URLs
# This allows use of the /wiki/* path
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "{{ MW_SCRIPT_PATH }}";
$wgArticlePath = "/wiki/$1";

#Set Secret
$wgSecretKey = "secretkey";

// https://phabricator.wikimedia.org/T235554#6435256
$wgDisableOutputCompression  = true;

## RC Age
# https://www.mediawiki.org/wiki/Manual:
# Items in the recentchanges table are periodically purged; entries older than this many seconds will go.
# The query service (by default) loads data from recent changes
# Set this to 1 year to avoid any changes being removed from the RC table over a shorter period of time.
$wgRCMaxAge = 365 * 24 * 3600;

wfLoadSkin( 'Vector' );

## Wikibase
# Load Wikibase repo & client with the example / default settings.
wfLoadExtension( 'WikibaseRepository', "$IP/extensions/Wikibase/extension-repo.json" );
wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";

# UniversalLanguageSelector
wfLoadExtension( 'UniversalLanguageSelector' );

# cldr
wfLoadExtension( 'cldr' );

$wgWBClientSettings = $wgWBClientSettings ?? [];

# Federated Properties
$wgWBRepoSettings['federatedPropertiesEnabled'] = true;
$wgWBRepoSettings['federatedPropertiesSourceScriptUrl'] = "{{ SOURCE_REPO_SCHEME }}://{{ SOURCE_REPO_HOST }}/w/";

if('{{ FEDPROPS_INTERWIKI_PREFIX }}' !== 'wikidata') {
    $wgWBRepoSettings['entitySources'] = [
        'local' => [
            'entityNamespaces' => [ 'item' => 120, 'property' => 122 ],
            'repoDatabase' => false,
            'baseUri' => 'http://{{ SERVER_NAME }}/entity/',
            'interwikiPrefix' => '',
            'rdfNodeNamespacePrefix' => 'wd',
            'rdfPredicateNamespacePrefix' => 'wdt',
        ],
        'fedprops' => [
            'type' => 'api',
            'entityTypes' => [ 'property' ],
            'baseUri' => 'http://{{ SOURCE_REPO_HOST }}/entity/',
            'interwikiPrefix' => '{{ FEDPROPS_INTERWIKI_PREFIX }}',
            'rdfNodeNamespacePrefix' => 'fpwd',
            'rdfPredicateNamespacePrefix' => 'fpwd',
        ],
    ];
}

# simulate source API errors via request header
if( isset ( $_SERVER['HTTP_X_FEDPROPS_SOURCEAPIRESPONSE'] ) ) {
   $wgParserCacheType = CACHE_NONE;
   $code = $_SERVER['HTTP_X_FEDPROPS_SOURCEAPIRESPONSE'];

   if( $code == 404 ) {
      $wgWBRepoSettings['federatedPropertiesSourceScriptUrl'] = 'http://notFound.404';
   }
}

# WikibaseCirrusSearch / Elastic
wfLoadExtension( 'WikibaseCirrusSearch' );
wfLoadExtension( 'CirrusSearch' );
wfLoadExtension( 'Elastica' );

require_once "$IP/extensions/CirrusSearch/tests/jenkins/FullyFeaturedConfig.php";
$wgCirrusSearchServers = [ 'elasticsearch' ];
$wgWBCSUseCirrus = true;

# Spam protection
wfLoadExtensions([ 'ConfirmEdit', 'ConfirmEdit/QuestyCaptcha' ]);

$wgCaptchaQuestions = [
    'What\'s the name of the feature that we are testing on this test system?' => [ 'Federated Properties', 'FeddyProps' ],
    'What does WB stand for?' => 'Wikibase'
];
$wgCaptchaTriggers['createaccount'] = true;

# Only logged in users have the move permission, so only logged in users can edit the MAIN and TALK namespaces
$wgNamespaceProtection[NS_MAIN] = ['move'];
$wgNamespaceProtection[NS_TALK] = ['move'];
$wgNamespaceProtection[NS_USER] = ['move'];
$wgNamespaceProtection[NS_USER_TALK] = ['move'];