MediaWiki  1.32.0
ApiQuerySiteinfoTest.php
Go to the documentation of this file.
1 <?php
2 
4 
13  // We don't try to test every single thing for every category, just a sample
14 
15  protected function doQuery( $siprop = null, $extraParams = [] ) {
16  $params = [ 'action' => 'query', 'meta' => 'siteinfo' ];
17  if ( $siprop !== null ) {
18  $params['siprop'] = $siprop;
19  }
20  $params = array_merge( $params, $extraParams );
21 
22  $res = $this->doApiRequest( $params );
23 
24  $this->assertArrayNotHasKey( 'warnings', $res[0] );
25  $this->assertCount( 1, $res[0]['query'] );
26 
27  return $res[0]['query'][$siprop === null ? 'general' : $siprop];
28  }
29 
30  public function testGeneral() {
31  $this->setMwGlobals( [
32  'wgAllowExternalImagesFrom' => '//localhost/',
33  ] );
34 
35  $data = $this->doQuery();
36 
37  $this->assertSame( Title::newMainPage()->getPrefixedText(), $data['mainpage'] );
38  $this->assertSame( PHP_VERSION, $data['phpversion'] );
39  $this->assertSame( [ '//localhost/' ], $data['externalimages'] );
40  }
41 
42  public function testLinkPrefixCharset() {
43  global $wgContLang;
44 
45  $this->setContentLang( 'ar' );
46  $this->assertTrue( $wgContLang->linkPrefixExtension(), 'Sanity check' );
47 
48  $data = $this->doQuery();
49 
50  $this->assertSame( $wgContLang->linkPrefixCharset(), $data['linkprefixcharset'] );
51  }
52 
53  public function testVariants() {
54  global $wgContLang;
55 
56  $this->setContentLang( 'zh' );
57  $this->assertTrue( $wgContLang->hasVariants(), 'Sanity check' );
58 
59  $data = $this->doQuery();
60 
61  $expected = array_map(
62  function ( $code ) use ( $wgContLang ) {
63  return [ 'code' => $code, 'name' => $wgContLang->getVariantname( $code ) ];
64  },
65  $wgContLang->getVariants()
66  );
67 
68  $this->assertSame( $expected, $data['variants'] );
69  }
70 
71  public function testReadOnly() {
72  $svc = \MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode();
73  $svc->setReason( 'Need more donations' );
74  try {
75  $data = $this->doQuery();
76  } finally {
77  $svc->setReason( false );
78  }
79 
80  $this->assertTrue( $data['readonly'] );
81  $this->assertSame( 'Need more donations', $data['readonlyreason'] );
82  }
83 
84  public function testNamespaces() {
85  global $wgContLang;
86 
87  $this->setMwGlobals( 'wgExtraNamespaces', [ '138' => 'Testing' ] );
88 
89  $this->assertSame( array_keys( $wgContLang->getFormattedNamespaces() ),
90  array_keys( $this->doQuery( 'namespaces' ) ) );
91  }
92 
93  public function testNamespaceAliases() {
95 
96  $expected = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() );
97  $expected = array_map(
98  function ( $key, $val ) {
99  return [ 'id' => $val, 'alias' => strtr( $key, '_', ' ' ) ];
100  },
101  array_keys( $expected ),
102  $expected
103  );
104 
105  // Test that we don't list duplicates
106  $this->mergeMwGlobalArrayValue( 'wgNamespaceAliases', [ 'Talk' => NS_TALK ] );
107 
108  $this->assertSame( $expected, $this->doQuery( 'namespacealiases' ) );
109  }
110 
111  public function testSpecialPageAliases() {
112  $this->assertCount(
113  count( MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames() ),
114  $this->doQuery( 'specialpagealiases' )
115  );
116  }
117 
118  public function testMagicWords() {
119  global $wgContLang;
120 
121  $this->assertCount(
122  count( $wgContLang->getMagicWords() ),
123  $this->doQuery( 'magicwords' )
124  );
125  }
126 
130  public function testInterwikiMap( $filter ) {
131  global $wgServer, $wgScriptPath;
132 
133  $dbw = wfGetDB( DB_MASTER );
134  $dbw->insert(
135  'interwiki',
136  [
137  [
138  'iw_prefix' => 'self',
139  'iw_url' => "$wgServer$wgScriptPath/index.php?title=$1",
140  'iw_api' => "$wgServer$wgScriptPath/api.php",
141  'iw_wikiid' => 'somedbname',
142  'iw_local' => true,
143  'iw_trans' => true,
144  ],
145  [
146  'iw_prefix' => 'foreign',
147  'iw_url' => '//foreign.example/wiki/$1',
148  'iw_api' => '',
149  'iw_wikiid' => '',
150  'iw_local' => false,
151  'iw_trans' => false,
152  ],
153  ],
154  __METHOD__,
155  'IGNORE'
156  );
157  $this->tablesUsed[] = 'interwiki';
158 
159  $this->setMwGlobals( [
160  'wgLocalInterwikis' => [ 'self' ],
161  'wgExtraInterlanguageLinkPrefixes' => [ 'self' ],
162  'wgExtraLanguageNames' => [ 'self' => 'Recursion' ],
163  ] );
164 
165  MessageCache::singleton()->enable();
166 
167  $this->editPage( 'MediaWiki:Interlanguage-link-self', 'Self!' );
168  $this->editPage( 'MediaWiki:Interlanguage-link-sitename-self', 'Circular logic' );
169 
170  $expected = [];
171 
172  if ( $filter === null || $filter === '!local' ) {
173  $expected[] = [
174  'prefix' => 'foreign',
175  'url' => wfExpandUrl( '//foreign.example/wiki/$1', PROTO_CURRENT ),
176  'protorel' => true,
177  ];
178  }
179  if ( $filter === null || $filter === 'local' ) {
180  $expected[] = [
181  'prefix' => 'self',
182  'local' => true,
183  'trans' => true,
184  'language' => 'Recursion',
185  'localinterwiki' => true,
186  'extralanglink' => true,
187  'linktext' => 'Self!',
188  'sitename' => 'Circular logic',
189  'url' => "$wgServer$wgScriptPath/index.php?title=$1",
190  'protorel' => false,
191  'wikiid' => 'somedbname',
192  'api' => "$wgServer$wgScriptPath/api.php",
193  ];
194  }
195 
196  $data = $this->doQuery( 'interwikimap',
197  $filter === null ? [] : [ 'sifilteriw' => $filter ] );
198 
199  $this->assertSame( $expected, $data );
200  }
201 
202  public function interwikiMapProvider() {
203  return [ [ 'local' ], [ '!local' ], [ null ] ];
204  }
205 
209  public function testDbReplLagInfo( $showHostnames, $includeAll ) {
210  if ( !$showHostnames && $includeAll ) {
211  $this->setExpectedApiException( 'apierror-siteinfo-includealldenied' );
212  }
213 
214  $mockLB = $this->getMockBuilder( LoadBalancer::class )
215  ->disableOriginalConstructor()
216  ->setMethods( [ 'getMaxLag', 'getLagTimes', 'getServerName', '__destruct' ] )
217  ->getMock();
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' ]
222  ] ) );
223  $this->setService( 'DBLoadBalancer', $mockLB );
224 
225  $this->setMwGlobals( 'wgShowHostnames', $showHostnames );
226 
227  $expected = [];
228  if ( $includeAll ) {
229  $expected[] = [ 'host' => $showHostnames ? 'apple' : '', 'lag' => 5 ];
230  }
231  $expected[] = [ 'host' => $showHostnames ? 'carrot' : '', 'lag' => 7 ];
232 
233  $data = $this->doQuery( 'dbrepllag', $includeAll ? [ 'sishowalldb' => '' ] : [] );
234 
235  $this->assertSame( $expected, $data );
236  }
237 
238  public function dbReplLagProvider() {
239  return [
240  'no hostnames, no showalldb' => [ false, false ],
241  'no hostnames, showalldb' => [ false, true ],
242  'hostnames, no showalldb' => [ true, false ],
243  'hostnames, showalldb' => [ true, true ]
244  ];
245  }
246 
247  public function testStatistics() {
248  $this->setTemporaryHook( 'APIQuerySiteInfoStatisticsInfo',
249  function ( &$data ) {
250  $data['addedstats'] = 42;
251  }
252  );
253 
254  $expected = [
255  'pages' => intval( SiteStats::pages() ),
256  'articles' => intval( SiteStats::articles() ),
257  'edits' => intval( SiteStats::edits() ),
258  'images' => intval( SiteStats::images() ),
259  'users' => intval( SiteStats::users() ),
260  'activeusers' => intval( SiteStats::activeUsers() ),
261  'admins' => intval( SiteStats::numberingroup( 'sysop' ) ),
262  'jobs' => intval( SiteStats::jobs() ),
263  'addedstats' => 42,
264  ];
265 
266  $this->assertSame( $expected, $this->doQuery( 'statistics' ) );
267  }
268 
272  public function testUserGroups( $numInGroup ) {
274 
275  $this->setGroupPermissions( 'viscount', 'perambulate', 'yes' );
276  $this->setGroupPermissions( 'viscount', 'legislate', '0' );
277  $this->setMwGlobals( [
278  'wgAddGroups' => [ 'viscount' => true, 'bot' => [] ],
279  'wgRemoveGroups' => [ 'viscount' => [ 'sysop' ], 'bot' => [ '*', 'earl' ] ],
280  'wgGroupsAddToSelf' => [ 'bot' => [ 'bureaucrat', 'sysop' ] ],
281  'wgGroupsRemoveFromSelf' => [ 'bot' => [ 'bot' ] ],
282  ] );
283 
284  $data = $this->doQuery( 'usergroups', $numInGroup ? [ 'sinumberingroup' => '' ] : [] );
285 
286  $names = array_map(
287  function ( $val ) {
288  return $val['name'];
289  },
290  $data
291  );
292 
293  $this->assertSame( array_keys( $wgGroupPermissions ), $names );
294 
295  foreach ( $data as $val ) {
296  if ( !$numInGroup ) {
297  $expectedSize = null;
298  } elseif ( $val['name'] === 'user' ) {
299  $expectedSize = SiteStats::users();
300  } elseif ( $val['name'] === '*' || isset( $wgAutopromote[$val['name']] ) ) {
301  $expectedSize = null;
302  } else {
303  $expectedSize = SiteStats::numberingroup( $val['name'] );
304  }
305 
306  if ( $expectedSize === null ) {
307  $this->assertArrayNotHasKey( 'number', $val );
308  } else {
309  $this->assertSame( $expectedSize, $val['number'] );
310  }
311 
312  if ( $val['name'] === 'viscount' ) {
313  $viscountFound = true;
314  $this->assertSame( [ 'perambulate' ], $val['rights'] );
315  $this->assertSame( User::getAllGroups(), $val['add'] );
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'] );
321  }
322  }
323  }
324 
325  public function testFileExtensions() {
326  global $wgFileExtensions;
327 
328  // Add duplicate
329  $this->setMwGlobals( 'wgFileExtensions', array_merge( $wgFileExtensions, [ 'png' ] ) );
330 
331  $expected = array_map(
332  function ( $val ) {
333  return [ 'ext' => $val ];
334  },
335  array_unique( $wgFileExtensions )
336  );
337 
338  $this->assertSame( $expected, $this->doQuery( 'fileextensions' ) );
339  }
340 
341  public function groupsProvider() {
342  return [
343  'numingroup' => [ true ],
344  'nonumingroup' => [ false ],
345  ];
346  }
347 
348  public function testInstalledLibraries() {
349  // @todo Test no installed.json? Moving installed.json to a different name temporarily
350  // seems a bit scary, but I don't see any other way to do it.
351  //
352  // @todo Install extensions/skins somehow so that we can test they're filtered out
353  global $IP;
354 
355  $path = "$IP/vendor/composer/installed.json";
356  if ( !file_exists( $path ) ) {
357  $this->markTestSkipped( 'No installed libraries' );
358  }
359 
360  $expected = ( new ComposerInstalled( $path ) )->getInstalledDependencies();
361 
362  $expected = array_filter( $expected,
363  function ( $info ) {
364  return strpos( $info['type'], 'mediawiki-' ) !== 0;
365  }
366  );
367 
368  $expected = array_map(
369  function ( $name, $info ) {
370  return [ 'name' => $name, 'version' => $info['version'] ];
371  },
372  array_keys( $expected ),
373  array_values( $expected )
374  );
375 
376  $this->assertSame( $expected, $this->doQuery( 'libraries' ) );
377  }
378 
379  public function testExtensions() {
380  $tmpdir = $this->getNewTempDirectory();
381  touch( "$tmpdir/ErsatzExtension.php" );
382  touch( "$tmpdir/LICENSE" );
383  touch( "$tmpdir/AUTHORS.txt" );
384 
385  $val = [
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',
395  ];
396 
397  $this->setMwGlobals( 'wgExtensionCredits', [ 'api' => [
398  $val,
399  [
400  'author' => [ 'John Smith', 'John Smith Jr.', '...' ],
401  'descriptionmsg' => [ 'another-extension-desc', 'param' ] ],
402  ] ] );
403 
404  $data = $this->doQuery( 'extensions' );
405 
406  $this->assertCount( 2, $data );
407 
408  $this->assertSame( 'api', $data[0]['type'] );
409 
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] );
414  }
415 
416  // @todo Test git info
417 
418  $this->assertSame(
419  Title::newFromText( 'Special:Version/License/Ersatz Extension' )->getLinkURL(),
420  $data[0]['license']
421  );
422 
423  $this->assertSame(
424  Title::newFromText( 'Special:Version/Credits/Ersatz Extension' )->getLinkURL(),
425  $data[0]['credits']
426  );
427 
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'] );
431  }
432 
436  public function testRightsInfo( $page, $url, $text, $expectedUrl, $expectedText ) {
437  $this->setMwGlobals( [
438  'wgRightsPage' => $page,
439  'wgRightsUrl' => $url,
440  'wgRightsText' => $text,
441  ] );
442 
443  $this->assertSame(
444  [ 'url' => $expectedUrl, 'text' => $expectedText ],
445  $this->doQuery( 'rightsinfo' )
446  );
447  }
448 
449  public function rightsInfoProvider() {
450  $textUrl = wfExpandUrl( Title::newFromText( 'License' ), PROTO_CURRENT );
451  $url = 'http://license.example/';
452 
453  return [
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, '!!!', '', '!!!' ],
458  // URL is ignored if page is specified
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,
464  wfExpandUrl( Title::newFromText( '0' ), PROTO_CURRENT ), '0' ],
465  'URL "0"' => [ null, '0', null, '0', '' ],
466  'Text "0"' => [ null, null, '0', '', '0' ],
467  ];
468  }
469 
470  public function testRestrictions() {
473 
474  $this->assertSame( [
475  'types' => $wgRestrictionTypes,
476  'levels' => $wgRestrictionLevels,
477  'cascadinglevels' => $wgCascadingRestrictionLevels,
478  'semiprotectedlevels' => $wgSemiprotectedRestrictionLevels,
479  ], $this->doQuery( 'restrictions' ) );
480  }
481 
485  public function testLanguages( $langCode ) {
486  $expected = Language::fetchLanguageNames( (string)$langCode );
487 
488  $expected = array_map(
489  function ( $code, $name ) {
490  return [
491  'code' => $code,
492  'bcp47' => LanguageCode::bcp47( $code ),
493  'name' => $name
494  ];
495  },
496  array_keys( $expected ),
497  array_values( $expected )
498  );
499 
500  $data = $this->doQuery( 'languages',
501  $langCode !== null ? [ 'siinlanguagecode' => $langCode ] : [] );
502 
503  $this->assertSame( $expected, $data );
504  }
505 
506  public function languagesProvider() {
507  return [ [ null ], [ 'fr' ] ];
508  }
509 
510  public function testLanguageVariants() {
511  $expectedKeys = array_filter( LanguageConverter::$languagesWithVariants,
512  function ( $langCode ) {
513  return !Language::factory( $langCode )->getConverter() instanceof FakeConverter;
514  }
515  );
516  sort( $expectedKeys );
517 
518  $this->assertSame( $expectedKeys, array_keys( $this->doQuery( 'languagevariants' ) ) );
519  }
520 
521  public function testLanguageVariantsDisabled() {
522  $this->setMwGlobals( 'wgDisableLangConversion', true );
523 
524  $this->assertSame( [], $this->doQuery( 'languagevariants' ) );
525  }
526 
535  public function testSkins( $code ) {
536  $data = $this->doQuery( 'skins', $code !== null ? [ 'siinlanguagecode' => $code ] : [] );
537 
538  $expectedAllowed = Skin::getAllowedSkins();
539  $expectedDefault = Skin::normalizeKey( 'default' );
540 
541  $i = 0;
542  foreach ( Skin::getSkinNames() as $name => $displayName ) {
543  $this->assertSame( $name, $data[$i]['code'] );
544 
545  $msg = wfMessage( "skinname-$name" );
546  if ( $code && Language::isValidCode( $code ) ) {
547  $msg->inLanguage( $code );
548  } else {
549  $msg->inContentLanguage();
550  }
551  if ( $msg->exists() ) {
552  $displayName = $msg->text();
553  }
554  $this->assertSame( $displayName, $data[$i]['name'] );
555 
556  if ( !isset( $expectedAllowed[$name] ) ) {
557  $this->assertTrue( $data[$i]['unusable'], "$name must be unusable" );
558  }
559  if ( $name === $expectedDefault ) {
560  $this->assertTrue( $data[$i]['default'], "$expectedDefault must be default" );
561  }
562  $i++;
563  }
564  }
565 
566  public function skinsProvider() {
567  return [
568  'No language specified' => [ null ],
569  'Czech' => [ 'cs' ],
570  'Invalid language' => [ '/invalid/' ],
571  ];
572  }
573 
574  public function testExtensionTags() {
575  global $wgParser;
576 
577  $expected = array_map(
578  function ( $tag ) {
579  return "<$tag>";
580  },
581  $wgParser->getTags()
582  );
583 
584  $this->assertSame( $expected, $this->doQuery( 'extensiontags' ) );
585  }
586 
587  public function testFunctionHooks() {
588  global $wgParser;
589 
590  $this->assertSame( $wgParser->getFunctionHooks(), $this->doQuery( 'functionhooks' ) );
591  }
592 
593  public function testVariables() {
594  $this->assertSame( MagicWord::getVariableIDs(), $this->doQuery( 'variables' ) );
595  }
596 
597  public function testProtocols() {
598  global $wgUrlProtocols;
599 
600  $this->assertSame( $wgUrlProtocols, $this->doQuery( 'protocols' ) );
601  }
602 
603  public function testDefaultOptions() {
604  $this->assertSame( User::getDefaultOptions(), $this->doQuery( 'defaultoptions' ) );
605  }
606 
607  public function testUploadDialog() {
608  global $wgUploadDialog;
609 
610  $this->assertSame( $wgUploadDialog, $this->doQuery( 'uploaddialog' ) );
611  }
612 
613  public function testGetHooks() {
614  global $wgHooks;
615 
616  // Make sure there's something to report on
617  $this->setTemporaryHook( 'somehook',
618  function () {
619  return;
620  }
621  );
622 
623  $expectedNames = $wgHooks;
624  ksort( $expectedNames );
625 
626  $actualNames = array_map(
627  function ( $val ) {
628  return $val['name'];
629  },
630  $this->doQuery( 'showhooks' )
631  );
632 
633  $this->assertSame( array_keys( $expectedNames ), $actualNames );
634  }
635 
636  public function testContinuation() {
637  // We make lots and lots of URL protocols that are each 100 bytes
639 
640  $this->setMwGlobals( 'wgUrlProtocols', [] );
641 
642  // Just under the limit
643  $chunks = $wgAPIMaxResultSize / 100 - 1;
644 
645  for ( $i = 0; $i < $chunks; $i++ ) {
646  $wgUrlProtocols[] = substr( str_repeat( "$i ", 50 ), 0, 100 );
647  }
648 
649  $res = $this->doApiRequest( [
650  'action' => 'query',
651  'meta' => 'siteinfo',
652  'siprop' => 'protocols|languages',
653  ] );
654 
655  $this->assertSame(
656  wfMessage( 'apiwarn-truncatedresult', Message::numParam( $wgAPIMaxResultSize ) )
657  ->text(),
658  $res[0]['warnings']['result']['warnings']
659  );
660 
661  $this->assertSame( $wgUrlProtocols, $res[0]['query']['protocols'] );
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'] );
665  }
666 }
SiteStats\articles
static articles()
Definition: SiteStats.php:103
ApiQuerySiteinfoTest\testSpecialPageAliases
testSpecialPageAliases()
Definition: ApiQuerySiteinfoTest.php:111
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:280
ApiQuerySiteinfoTest
API medium Database.
Definition: ApiQuerySiteinfoTest.php:12
ApiQuerySiteinfoTest\groupsProvider
groupsProvider()
Definition: ApiQuerySiteinfoTest.php:341
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
SiteStats\users
static users()
Definition: SiteStats.php:121
$wgParser
$wgParser
Definition: Setup.php:913
MediaWikiTestCase\mergeMwGlobalArrayValue
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
Definition: MediaWikiTestCase.php:901
SiteStats\activeUsers
static activeUsers()
Definition: SiteStats.php:130
ApiQuerySiteinfoTest\testLinkPrefixCharset
testLinkPrefixCharset()
Definition: ApiQuerySiteinfoTest.php:42
ApiQuerySiteinfoTest\testFileExtensions
testFileExtensions()
Definition: ApiQuerySiteinfoTest.php:325
captcha-old.count
count
Definition: captcha-old.py:249
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:597
SiteStats\pages
static pages()
Definition: SiteStats.php:112
ApiQuerySiteinfoTest\testGetHooks
testGetHooks()
Definition: ApiQuerySiteinfoTest.php:613
ApiQuerySiteinfoTest\testRestrictions
testRestrictions()
Definition: ApiQuerySiteinfoTest.php:470
SiteStats\numberingroup
static numberingroup( $group)
Find the number of users in a given user group.
Definition: SiteStats.php:150
$wgFileExtensions
$wgFileExtensions
This is the list of preferred extensions for uploading files.
Definition: DefaultSettings.php:931
$params
$params
Definition: styleTest.css.php:44
ApiQuerySiteinfoTest\testMagicWords
testMagicWords()
Definition: ApiQuerySiteinfoTest.php:118
ApiQuerySiteinfoTest\interwikiMapProvider
interwikiMapProvider()
Definition: ApiQuerySiteinfoTest.php:202
ApiQuerySiteinfoTest\testExtensions
testExtensions()
Definition: ApiQuerySiteinfoTest.php:379
ApiQuerySiteinfoTest\testLanguageVariants
testLanguageVariants()
Definition: ApiQuerySiteinfoTest.php:510
$res
$res
Definition: database.txt:21
ApiQuerySiteinfoTest\testInterwikiMap
testInterwikiMap( $filter)
interwikiMapProvider
Definition: ApiQuerySiteinfoTest.php:130
php
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
Definition: injection.txt:35
Skin\getSkinNames
static getSkinNames()
Fetch the set of available skins.
Definition: Skin.php:57
User\getDefaultOptions
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
Definition: User.php:1773
SiteStats\images
static images()
Definition: SiteStats.php:139
ApiTestCase\doApiRequest
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
Definition: ApiTestCase.php:63
ApiQuerySiteinfoTest\doQuery
doQuery( $siprop=null, $extraParams=[])
Definition: ApiQuerySiteinfoTest.php:15
$wgAutopromote
$wgAutopromote
Array containing the conditions of automatic promotion of a user to specific groups.
Definition: DefaultSettings.php:5466
MagicWord\getVariableIDs
static getVariableIDs()
Get an array of parser variable IDs.
Definition: MagicWord.php:137
ApiQuerySiteinfoTest\testVariables
testVariables()
Definition: ApiQuerySiteinfoTest.php:593
ApiQuerySiteinfoTest\testDefaultOptions
testDefaultOptions()
Definition: ApiQuerySiteinfoTest.php:603
ApiQuerySiteinfoTest\testNamespaceAliases
testNamespaceAliases()
Definition: ApiQuerySiteinfoTest.php:93
Skin\normalizeKey
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition: Skin.php:101
ApiQuerySiteinfoTest\testContinuation
testContinuation()
Definition: ApiQuerySiteinfoTest.php:636
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2693
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:706
$IP
$IP
Definition: update.php:3
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:222
use
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
Definition: MIT-LICENSE.txt:10
$code
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
Definition: hooks.txt:813
ApiQuerySiteinfoTest\testNamespaces
testNamespaces()
Definition: ApiQuerySiteinfoTest.php:84
DB_MASTER
const DB_MASTER
Definition: defines.php:26
$wgAPIMaxResultSize
$wgAPIMaxResultSize
The maximum size (in bytes) of an API result.
Definition: DefaultSettings.php:8192
MessageCache\singleton
static singleton()
Get the signleton instance of this class.
Definition: MessageCache.php:114
MediaWikiTestCase\setContentLang
setContentLang( $lang)
Definition: MediaWikiTestCase.php:1063
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ApiQuerySiteinfoTest\testReadOnly
testReadOnly()
Definition: ApiQuerySiteinfoTest.php:71
$wgNamespaceAliases
$wgNamespaceAliases
Namespace aliases.
Definition: DefaultSettings.php:3904
MediaWikiTestCase\editPage
editPage( $pageName, $text, $summary='', $defaultNs=NS_MAIN)
Edits or creates a page/revision.
Definition: MediaWikiTestCase.php:2333
ApiQuerySiteinfoTest\testGeneral
testGeneral()
Definition: ApiQuerySiteinfoTest.php:30
ApiTestCase
Definition: ApiTestCase.php:5
ApiQuerySiteinfoTest\testInstalledLibraries
testInstalledLibraries()
Definition: ApiQuerySiteinfoTest.php:348
$wgUrlProtocols
$wgUrlProtocols
URL schemes that should be recognized as valid by wfParseUrl().
Definition: DefaultSettings.php:4208
ApiQuerySiteinfoTest\testUploadDialog
testUploadDialog()
Definition: ApiQuerySiteinfoTest.php:607
$wgServer
$wgServer
URL of the server.
Definition: DefaultSettings.php:105
ApiQuerySiteinfoTest\testVariants
testVariants()
Definition: ApiQuerySiteinfoTest.php:53
ApiQuerySiteinfoTest\testFunctionHooks
testFunctionHooks()
Definition: ApiQuerySiteinfoTest.php:587
$wgUploadDialog
$wgUploadDialog
Configuration for file uploads using the embeddable upload dialog (https://www.mediawiki....
Definition: DefaultSettings.php:675
SiteStats\jobs
static jobs()
Total number of jobs in the job queue.
Definition: SiteStats.php:179
ApiQuerySiteinfoTest\testExtensionTags
testExtensionTags()
Definition: ApiQuerySiteinfoTest.php:574
User\getAllGroups
static getAllGroups()
Return the set of defined explicit groups.
Definition: User.php:5108
MediaWikiTestCase\setGroupPermissions
setGroupPermissions( $newPerms, $newKey=null, $newValue=null)
Alters $wgGroupPermissions for the duration of the test.
Definition: MediaWikiTestCase.php:1092
Language\isValidCode
static isValidCode( $code)
Returns true if a language code string is of a valid form, whether or not it exists.
Definition: Language.php:386
FakeConverter
A fake language variant converter.
Definition: FakeConverter.php:34
ApiQuerySiteinfoTest\testDbReplLagInfo
testDbReplLagInfo( $showHostnames, $includeAll)
dbReplLagProvider
Definition: ApiQuerySiteinfoTest.php:209
ApiQuerySiteinfoTest\testStatistics
testStatistics()
Definition: ApiQuerySiteinfoTest.php:247
$wgCascadingRestrictionLevels
$wgCascadingRestrictionLevels
Restriction levels that can be used with cascading protection.
Definition: DefaultSettings.php:5340
ApiQuerySiteinfoTest\languagesProvider
languagesProvider()
Definition: ApiQuerySiteinfoTest.php:506
text
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
Definition: All_system_messages.txt:1267
ApiQuerySiteinfoTest\testLanguages
testLanguages( $langCode)
languagesProvider
Definition: ApiQuerySiteinfoTest.php:485
$wgSemiprotectedRestrictionLevels
$wgSemiprotectedRestrictionLevels
Restriction levels that should be considered "semiprotected".
Definition: DefaultSettings.php:5354
ApiTestCase\setExpectedApiException
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...
Definition: ApiTestCase.php:217
ApiQuerySiteinfoTest\testRightsInfo
testRightsInfo( $page, $url, $text, $expectedUrl, $expectedText)
rightsInfoProvider
Definition: ApiQuerySiteinfoTest.php:436
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:108
$path
$path
Definition: NoLocalSettings.php:25
as
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
Definition: distributors.txt:9
LanguageCode\bcp47
static bcp47( $code)
Get the normalised IETF language tag See unit test for examples.
Definition: LanguageCode.php:182
ApiQuerySiteinfoTest\rightsInfoProvider
rightsInfoProvider()
Definition: ApiQuerySiteinfoTest.php:449
ApiQuerySiteinfoTest\testSkins
testSkins( $code)
Definition: ApiQuerySiteinfoTest.php:535
$wgRestrictionLevels
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
Definition: DefaultSettings.php:5329
ApiQuerySiteinfoTest\testLanguageVariantsDisabled
testLanguageVariantsDisabled()
Definition: ApiQuerySiteinfoTest.php:521
true
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
Definition: hooks.txt:2036
ApiQuerySiteinfoTest\testUserGroups
testUserGroups( $numInGroup)
groupsProvider
Definition: ApiQuerySiteinfoTest.php:272
NS_TALK
const NS_TALK
Definition: Defines.php:65
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:214
$wgRestrictionTypes
$wgRestrictionTypes
Set of available actions that can be restricted via action=protect You probably shouldn't change this...
Definition: DefaultSettings.php:5316
$wgGroupPermissions
$wgGroupPermissions['sysop']['replacetext']
Definition: ReplaceText.php:56
class
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
Definition: maintenance.txt:52
ApiQuerySiteinfoTest\testProtocols
testProtocols()
Definition: ApiQuerySiteinfoTest.php:597
ApiQuerySiteinfoTest\dbReplLagProvider
dbReplLagProvider()
Definition: ApiQuerySiteinfoTest.php:238
MediaWikiTestCase\setTemporaryHook
setTemporaryHook( $hookName, $handler)
Create a temporary hook handler which will be reset by tearDown.
Definition: MediaWikiTestCase.php:2291
MediaWikiServices
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
Definition: injection.txt:23
Skin\getAllowedSkins
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition: Skin.php:80
Language\fetchLanguageNames
static fetchLanguageNames( $inLanguage=self::AS_AUTONYMS, $include='mw')
Get an array of language names, indexed by code.
Definition: Language.php:843
wfMessage
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 "&lt
$wgScriptPath
$wgScriptPath
The path we should point to.
Definition: DefaultSettings.php:137
ApiQuerySiteinfoTest\skinsProvider
skinsProvider()
Definition: ApiQuerySiteinfoTest.php:566
MediaWikiTestCase\setService
setService( $name, $object)
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown.
Definition: MediaWikiTestCase.php:646
$wgContLang
$wgContLang
Definition: Setup.php:809
ComposerInstalled
Reads an installed.json file and provides accessors to get what is installed.
Definition: ComposerInstalled.php:9
SiteStats\edits
static edits()
Definition: SiteStats.php:94
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:512
MediaWikiTestCase\getNewTempDirectory
getNewTempDirectory()
obtains a new temporary directory
Definition: MediaWikiTestCase.php:488