15 $this->mConf->suffixes = [
'wikipedia' =>
'wiki' ];
16 $this->mConf->wikis = [
'enwiki',
'dewiki',
'frwiki' ];
17 $this->mConf->settings = [
27 'default' =>
'default',
35 'default' =>
'$lang $site $wiki',
64 'default' =>
'default',
78 $GLOBALS[
'SomeGlobal'] = [
'SomeGlobal' =>
'SomeGlobal' ];
87 foreach ( $conf->suffixes
as $suffix ) {
88 if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
90 $lang = substr( $wiki, 0, -strlen( $suffix ) );
112 [
'wikipedia',
'en' ],
113 $this->mConf->siteFromDB(
'enwiki' ),
118 $this->mConf->siteFromDB(
'wiki' ),
119 'siteFromDB() on a suffix'
123 $this->mConf->siteFromDB(
'wikien' ),
124 'siteFromDB() on a non-existing wiki'
127 $this->mConf->suffixes = [
'wiki',
'' ];
130 $this->mConf->siteFromDB(
'wikien' ),
131 'siteFromDB() on a non-existing wiki (2)'
140 [
'enwiki',
'dewiki',
'frwiki' ],
141 $this->mConf->getLocalDatabases(),
142 'getLocalDatabases()'
153 $this->mConf->get(
'SimpleKey',
'enwiki',
'wiki' ),
154 'get(): simple setting on an existing wiki'
158 $this->mConf->get(
'SimpleKey',
'dewiki',
'wiki' ),
159 'get(): simple setting on an existing wiki (2)'
163 $this->mConf->get(
'SimpleKey',
'frwiki',
'wiki' ),
164 'get(): simple setting on an existing wiki (3)'
168 $this->mConf->get(
'SimpleKey',
'wiki',
'wiki' ),
169 'get(): simple setting on an suffix'
173 $this->mConf->get(
'SimpleKey',
'eswiki',
'wiki' ),
174 'get(): simple setting on an non-existing wiki'
180 $this->mConf->get(
'Fallback',
'enwiki',
'wiki' ),
181 'get(): fallback setting on an existing wiki'
185 $this->mConf->get(
'Fallback',
'dewiki',
'wiki', [], [
'tag' ] ),
186 'get(): fallback setting on an existing wiki (with wiki tag)'
190 $this->mConf->get(
'Fallback',
'frwiki',
'wiki', [], [
'tag' ] ),
191 'get(): no fallback if wiki has its own setting (matching tag)'
196 $this->mConf->get(
'Fallback',
'null_wiki',
'wiki', [], [
'tag' ] ),
197 'get(): no fallback if wiki has its own setting (matching tag and uses null)'
201 $this->mConf->get(
'Fallback',
'wiki',
'wiki' ),
202 'get(): fallback setting on an suffix'
206 $this->mConf->get(
'Fallback',
'wiki',
'wiki', [], [
'tag' ] ),
207 'get(): fallback setting on an suffix (with wiki tag)'
211 $this->mConf->get(
'Fallback',
'eswiki',
'wiki' ),
212 'get(): fallback setting on an non-existing wiki'
216 $this->mConf->get(
'Fallback',
'eswiki',
'wiki', [], [
'tag' ] ),
217 'get(): fallback setting on an non-existing wiki (with wiki tag)'
221 $common = [
'wiki' =>
'wiki',
'default' =>
'default' ];
222 $commonTag = [
'tag' =>
'tag',
'wiki' =>
'wiki',
'default' =>
'default' ];
224 [
'enwiki' =>
'enwiki' ] + $common,
225 $this->mConf->get(
'MergeIt',
'enwiki',
'wiki' ),
226 'get(): merging setting on an existing wiki'
229 [
'enwiki' =>
'enwiki' ] + $commonTag,
230 $this->mConf->get(
'MergeIt',
'enwiki',
'wiki', [], [
'tag' ] ),
231 'get(): merging setting on an existing wiki (with tag)'
234 [
'dewiki' =>
'dewiki' ] + $common,
235 $this->mConf->get(
'MergeIt',
'dewiki',
'wiki' ),
236 'get(): merging setting on an existing wiki (2)'
239 [
'dewiki' =>
'dewiki' ] + $commonTag,
240 $this->mConf->get(
'MergeIt',
'dewiki',
'wiki', [], [
'tag' ] ),
241 'get(): merging setting on an existing wiki (2) (with tag)'
244 [
'frwiki' =>
'frwiki' ] + $common,
245 $this->mConf->get(
'MergeIt',
'frwiki',
'wiki' ),
246 'get(): merging setting on an existing wiki (3)'
249 [
'frwiki' =>
'frwiki' ] + $commonTag,
250 $this->mConf->get(
'MergeIt',
'frwiki',
'wiki', [], [
'tag' ] ),
251 'get(): merging setting on an existing wiki (3) (with tag)'
254 [
'wiki' =>
'wiki' ] + $common,
255 $this->mConf->get(
'MergeIt',
'wiki',
'wiki' ),
256 'get(): merging setting on an suffix'
259 [
'wiki' =>
'wiki' ] + $commonTag,
260 $this->mConf->get(
'MergeIt',
'wiki',
'wiki', [], [
'tag' ] ),
261 'get(): merging setting on an suffix (with tag)'
265 $this->mConf->get(
'MergeIt',
'eswiki',
'wiki' ),
266 'get(): merging setting on an non-existing wiki'
270 $this->mConf->get(
'MergeIt',
'eswiki',
'wiki', [], [
'tag' ] ),
271 'get(): merging setting on an non-existing wiki (with tag)'
279 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
283 $this->mConf->siteFromDB(
'enwiki' ),
284 'siteFromDB() with callback'
288 $this->mConf->siteFromDB(
'wiki' ),
289 'siteFromDB() with callback on a suffix'
293 $this->mConf->siteFromDB(
'wikien' ),
294 'siteFromDB() with callback on a non-existing wiki'
302 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
306 $this->mConf->get(
'WithParams',
'enwiki',
'wiki' ),
307 'get(): parameter replacement on an existing wiki'
311 $this->mConf->get(
'WithParams',
'dewiki',
'wiki' ),
312 'get(): parameter replacement on an existing wiki (2)'
316 $this->mConf->get(
'WithParams',
'frwiki',
'wiki' ),
317 'get(): parameter replacement on an existing wiki (3)'
321 $this->mConf->get(
'WithParams',
'wiki',
'wiki' ),
322 'get(): parameter replacement on an suffix'
326 $this->mConf->get(
'WithParams',
'eswiki',
'wiki' ),
327 'get(): parameter replacement on an non-existing wiki'
335 $this->mConf->siteParamsCallback =
'SiteConfigurationTest::getSiteParamsCallback';
338 'SimpleKey' =>
'enwiki',
340 'WithParams' =>
'en wiki enwiki',
341 'SomeGlobal' => [
'enwiki' =>
'enwiki' ] +
$GLOBALS[
'SomeGlobal'],
343 'enwiki' =>
'enwiki',
346 'default' =>
'default'
349 $this->assertEquals( $getall, $this->mConf->getAll(
'enwiki' ),
'getAll()' );
351 $this->mConf->extractAllGlobals(
'enwiki',
'wiki' );
354 $getall[
'SimpleKey'],
356 'extractAllGlobals(): simple setting'
361 'extractAllGlobals(): fallback setting'
364 $getall[
'WithParams'],
366 'extractAllGlobals(): parameter replacement'
369 $getall[
'SomeGlobal'],
371 'extractAllGlobals(): merging with global'
376 'extractAllGlobals(): merging setting'
testGetAllGlobals()
SiteConfiguration::getAll.
testSiteFromDbWithCallback()
SiteConfiguration::siteFromDB.
testParameterReplacement()
SiteConfiguration::get.
testGetLocalDatabases()
SiteConfiguration::getLocalDatabases.
testSiteFromDb()
SiteConfiguration::siteFromDB.
static getSiteParamsCallback( $conf, $wiki)
This function is used as a callback within the tests below.
testGetConfVariables()
SiteConfiguration::get.
This is a class for holding configuration settings, particularly for multi-wiki sites.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
if(!isset( $args[0])) $lang