Go to the documentation of this file.
15 protected function doQuery( $siprop =
null, $extraParams = [] ) {
16 $params = [
'action' =>
'query',
'meta' =>
'siteinfo' ];
17 if ( $siprop !==
null ) {
24 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
25 $this->assertCount( 1,
$res[0][
'query'] );
27 return $res[0][
'query'][$siprop ===
null ?
'general' : $siprop];
32 'wgAllowExternalImagesFrom' =>
'//localhost/',
38 $this->assertSame( PHP_VERSION, $data[
'phpversion'] );
39 $this->assertSame( [
'//localhost/' ], $data[
'externalimages'] );
46 $this->assertTrue(
$wgContLang->linkPrefixExtension(),
'Sanity check' );
50 $this->assertSame(
$wgContLang->linkPrefixCharset(), $data[
'linkprefixcharset'] );
57 $this->assertTrue(
$wgContLang->hasVariants(),
'Sanity check' );
61 $expected = array_map(
68 $this->assertSame( $expected, $data[
'variants'] );
72 $svc = \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode();
73 $svc->setReason(
'Need more donations' );
77 $svc->setReason(
false );
80 $this->assertTrue( $data[
'readonly'] );
81 $this->assertSame(
'Need more donations', $data[
'readonlyreason'] );
87 $this->
setMwGlobals(
'wgExtraNamespaces', [
'138' =>
'Testing' ] );
89 $this->assertSame( array_keys(
$wgContLang->getFormattedNamespaces() ),
90 array_keys( $this->
doQuery(
'namespaces' ) ) );
97 $expected = array_map(
98 function ( $key, $val ) {
99 return [
'id' => $val,
'alias' => strtr( $key,
'_',
' ' ) ];
101 array_keys( $expected ),
108 $this->assertSame( $expected, $this->
doQuery(
'namespacealiases' ) );
113 count( MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames() ),
114 $this->
doQuery(
'specialpagealiases' )
138 'iw_prefix' =>
'self',
139 'iw_url' =>
"$wgServer$wgScriptPath/index.php?title=$1",
140 'iw_api' =>
"$wgServer$wgScriptPath/api.php",
141 'iw_wikiid' =>
'somedbname',
146 'iw_prefix' =>
'foreign',
147 'iw_url' =>
'//foreign.example/wiki/$1',
157 $this->tablesUsed[] =
'interwiki';
160 'wgLocalInterwikis' => [
'self' ],
161 'wgExtraInterlanguageLinkPrefixes' => [
'self' ],
162 'wgExtraLanguageNames' => [
'self' =>
'Recursion' ],
167 $this->
editPage(
'MediaWiki:Interlanguage-link-self',
'Self!' );
168 $this->
editPage(
'MediaWiki:Interlanguage-link-sitename-self',
'Circular logic' );
172 if ( $filter ===
null || $filter ===
'!local' ) {
174 'prefix' =>
'foreign',
179 if ( $filter ===
null || $filter ===
'local' ) {
184 'language' =>
'Recursion',
185 'localinterwiki' =>
true,
186 'extralanglink' =>
true,
187 'linktext' =>
'Self!',
188 'sitename' =>
'Circular logic',
189 'url' =>
"$wgServer$wgScriptPath/index.php?title=$1",
191 'wikiid' =>
'somedbname',
192 'api' =>
"$wgServer$wgScriptPath/api.php",
196 $data = $this->
doQuery(
'interwikimap',
197 $filter ===
null ? [] : [
'sifilteriw' => $filter ] );
199 $this->assertSame( $expected, $data );
203 return [ [
'local' ], [
'!local' ], [ null ] ];
210 if ( !$showHostnames && $includeAll ) {
215 ->disableOriginalConstructor()
216 ->setMethods( [
'getMaxLag',
'getLagTimes',
'getServerName',
'__destruct' ] )
218 $mockLB->method(
'getMaxLag' )->willReturn( [
null, 7, 1 ] );
219 $mockLB->method(
'getLagTimes' )->willReturn( [ 5, 7 ] );
220 $mockLB->method(
'getServerName' )->will( $this->returnValueMap( [
221 [ 0,
'apple' ], [ 1,
'carrot' ]
223 $this->
setService(
'DBLoadBalancer', $mockLB );
225 $this->
setMwGlobals(
'wgShowHostnames', $showHostnames );
229 $expected[] = [
'host' => $showHostnames ?
'apple' :
'',
'lag' => 5 ];
231 $expected[] = [
'host' => $showHostnames ?
'carrot' :
'',
'lag' => 7 ];
233 $data = $this->
doQuery(
'dbrepllag', $includeAll ? [
'sishowalldb' =>
'' ] : [] );
235 $this->assertSame( $expected, $data );
240 'no hostnames, no showalldb' => [
false,
false ],
241 'no hostnames, showalldb' => [
false,
true ],
242 'hostnames, no showalldb' => [
true,
false ],
243 'hostnames, showalldb' => [
true,
true ]
249 function ( &$data ) {
250 $data[
'addedstats'] = 42;
266 $this->assertSame( $expected, $this->
doQuery(
'statistics' ) );
278 'wgAddGroups' => [
'viscount' =>
true,
'bot' => [] ],
279 'wgRemoveGroups' => [
'viscount' => [
'sysop' ],
'bot' => [
'*',
'earl' ] ],
280 'wgGroupsAddToSelf' => [
'bot' => [
'bureaucrat',
'sysop' ] ],
281 'wgGroupsRemoveFromSelf' => [
'bot' => [
'bot' ] ],
284 $data = $this->
doQuery(
'usergroups', $numInGroup ? [
'sinumberingroup' =>
'' ] : [] );
295 foreach ( $data
as $val ) {
296 if ( !$numInGroup ) {
297 $expectedSize =
null;
298 } elseif ( $val[
'name'] ===
'user' ) {
300 } elseif ( $val[
'name'] ===
'*' || isset(
$wgAutopromote[$val[
'name']] ) ) {
301 $expectedSize =
null;
306 if ( $expectedSize ===
null ) {
307 $this->assertArrayNotHasKey(
'number', $val );
309 $this->assertSame( $expectedSize, $val[
'number'] );
312 if ( $val[
'name'] ===
'viscount' ) {
313 $viscountFound =
true;
314 $this->assertSame( [
'perambulate' ], $val[
'rights'] );
316 } elseif ( $val[
'name'] ===
'bot' ) {
317 $this->assertArrayNotHasKey(
'add', $val );
318 $this->assertArrayNotHasKey(
'remove', $val );
319 $this->assertSame( [
'bureaucrat',
'sysop' ], $val[
'add-self'] );
320 $this->assertSame( [
'bot' ], $val[
'remove-self'] );
331 $expected = array_map(
333 return [
'ext' => $val ];
338 $this->assertSame( $expected, $this->
doQuery(
'fileextensions' ) );
343 'numingroup' => [
true ],
344 'nonumingroup' => [
false ],
355 $path =
"$IP/vendor/composer/installed.json";
356 if ( !file_exists(
$path ) ) {
357 $this->markTestSkipped(
'No installed libraries' );
362 $expected = array_filter( $expected,
364 return strpos( $info[
'type'],
'mediawiki-' ) !== 0;
368 $expected = array_map(
369 function (
$name, $info ) {
370 return [
'name' =>
$name,
'version' => $info[
'version'] ];
372 array_keys( $expected ),
373 array_values( $expected )
376 $this->assertSame( $expected, $this->
doQuery(
'libraries' ) );
381 touch(
"$tmpdir/ErsatzExtension.php" );
382 touch(
"$tmpdir/LICENSE" );
383 touch(
"$tmpdir/AUTHORS.txt" );
386 'path' =>
"$tmpdir/ErsatzExtension.php",
387 'name' =>
'Ersatz Extension',
388 'namemsg' =>
'ersatz-extension-name',
389 'author' =>
'John Smith',
390 'version' =>
'0.0.2',
391 'url' =>
'https://www.example.com/software/ersatz-extension',
392 'description' =>
'An extension that is not what it seems.',
393 'descriptionmsg' =>
'ersatz-extension-desc',
394 'license-name' =>
'PD',
400 'author' => [
'John Smith',
'John Smith Jr.',
'...' ],
401 'descriptionmsg' => [
'another-extension-desc',
'param' ] ],
404 $data = $this->
doQuery(
'extensions' );
406 $this->assertCount( 2, $data );
408 $this->assertSame(
'api', $data[0][
'type'] );
410 $sharedKeys = [
'name',
'namemsg',
'description',
'descriptionmsg',
'author',
'url',
411 'version',
'license-name' ];
412 foreach ( $sharedKeys
as $key ) {
413 $this->assertSame( $val[$key], $data[0][$key] );
428 $this->assertSame(
'another-extension-desc', $data[1][
'descriptionmsg'] );
429 $this->assertSame( [
'param' ], $data[1][
'descriptionmsgparams'] );
430 $this->assertSame(
'John Smith, John Smith Jr., ...', $data[1][
'author'] );
436 public function testRightsInfo( $page, $url, $text, $expectedUrl, $expectedText ) {
438 'wgRightsPage' => $page,
439 'wgRightsUrl' => $url,
440 'wgRightsText' => $text,
444 [
'url' => $expectedUrl,
'text' => $expectedText ],
451 $url =
'http://license.example/';
454 'No rights info' => [
null,
null,
null,
'',
'' ],
455 'Only page' => [
'License',
null,
null, $textUrl,
'License' ],
456 'Only URL' => [
null, $url,
null, $url,
'' ],
457 'Only text' => [
null,
null,
'!!!',
'',
'!!!' ],
459 'Page and URL' => [
'License', $url,
null, $textUrl,
'License' ],
460 'URL and text' => [
null, $url,
'!!!', $url,
'!!!' ],
461 'Page and text' => [
'License',
null,
'!!!', $textUrl,
'!!!' ],
462 'Page and URL and text' => [
'License', $url,
'!!!', $textUrl,
'!!!' ],
463 'Pagename "0"' => [
'0',
null,
null,
465 'URL "0"' => [
null,
'0',
null,
'0',
'' ],
466 'Text "0"' => [
null,
null,
'0',
'',
'0' ],
479 ], $this->
doQuery(
'restrictions' ) );
488 $expected = array_map(
496 array_keys( $expected ),
497 array_values( $expected )
500 $data = $this->
doQuery(
'languages',
501 $langCode !==
null ? [
'siinlanguagecode' => $langCode ] : [] );
503 $this->assertSame( $expected, $data );
507 return [ [ null ], [
'fr' ] ];
511 $expectedKeys = array_filter( LanguageConverter::$languagesWithVariants,
512 function ( $langCode ) {
516 sort( $expectedKeys );
518 $this->assertSame( $expectedKeys, array_keys( $this->
doQuery(
'languagevariants' ) ) );
524 $this->assertSame( [], $this->
doQuery(
'languagevariants' ) );
536 $data = $this->
doQuery(
'skins',
$code !==
null ? [
'siinlanguagecode' =>
$code ] : [] );
543 $this->assertSame(
$name, $data[$i][
'code'] );
547 $msg->inLanguage(
$code );
549 $msg->inContentLanguage();
551 if ( $msg->exists() ) {
552 $displayName = $msg->text();
554 $this->assertSame( $displayName, $data[$i][
'name'] );
556 if ( !isset( $expectedAllowed[
$name] ) ) {
557 $this->assertTrue( $data[$i][
'unusable'],
"$name must be unusable" );
559 if (
$name === $expectedDefault ) {
560 $this->assertTrue( $data[$i][
'default'],
"$expectedDefault must be default" );
568 'No language specified' => [ null ],
570 'Invalid language' => [
'/invalid/' ],
577 $expected = array_map(
584 $this->assertSame( $expected, $this->
doQuery(
'extensiontags' ) );
590 $this->assertSame(
$wgParser->getFunctionHooks(), $this->
doQuery(
'functionhooks' ) );
624 ksort( $expectedNames );
626 $actualNames = array_map(
633 $this->assertSame( array_keys( $expectedNames ), $actualNames );
645 for ( $i = 0; $i < $chunks; $i++ ) {
651 'meta' =>
'siteinfo',
652 'siprop' =>
'protocols|languages',
658 $res[0][
'warnings'][
'result'][
'warnings']
662 $this->assertArrayNotHasKey(
'languages',
$res[0] );
663 $this->assertTrue(
$res[0][
'batchcomplete'],
'batchcomplete should be true' );
664 $this->assertSame( [
'siprop' =>
'languages',
'continue' =>
'-||' ],
$res[0][
'continue'] );
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
processing should stop and the error should be shown to the user * false
static newMainPage()
Create a new Title for the Main Page.
static numberingroup( $group)
Find the number of users in a given user group.
$wgFileExtensions
This is the list of preferred extensions for uploading files.
testInterwikiMap( $filter)
interwikiMapProvider
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
static getSkinNames()
Fetch the set of available skins.
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
doQuery( $siprop=null, $extraParams=[])
$wgAutopromote
Array containing the conditions of automatic promotion of a user to specific groups.
static getVariableIDs()
Get an array of parser variable IDs.
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
$wgAPIMaxResultSize
The maximum size (in bytes) of an API result.
static singleton()
Get the signleton instance of this class.
Allows to change the fields on the form that will be generated $name
$wgNamespaceAliases
Namespace aliases.
$wgUrlProtocols
URL schemes that should be recognized as valid by wfParseUrl().
$wgServer
URL of the server.
$wgUploadDialog
Configuration for file uploads using the embeddable upload dialog (https://www.mediawiki....
static jobs()
Total number of jobs in the job queue.
static getAllGroups()
Return the set of defined explicit groups.
static isValidCode( $code)
Returns true if a language code string is of a valid form, whether or not it exists.
A fake language variant converter.
testDbReplLagInfo( $showHostnames, $includeAll)
dbReplLagProvider
$wgCascadingRestrictionLevels
Restriction levels that can be used with cascading protection.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
testLanguages( $langCode)
languagesProvider
$wgSemiprotectedRestrictionLevels
Restriction levels that should be considered "semiprotected".
setExpectedApiException( $msg, $code=null, array $data=null, $httpCode=0)
Expect an ApiUsageException to be thrown with the given parameters, which are the same as ApiUsageExc...
testRightsInfo( $page, $url, $text, $expectedUrl, $expectedText)
rightsInfoProvider
$wgHooks['ArticleShow'][]
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
static bcp47( $code)
Get the normalised IETF language tag See unit test for examples.
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
testLanguageVariantsDisabled()
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
testUserGroups( $numInGroup)
groupsProvider
static factory( $code)
Get a cached or new language object for a given language code.
$wgRestrictionTypes
Set of available actions that can be restricted via action=protect You probably shouldn't change this...
$wgGroupPermissions['sysop']['replacetext']
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
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 MediaWikiServices
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
$wgScriptPath
The path we should point to.
Reads an installed.json file and provides accessors to get what is installed.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.