30 'setContentValue' =>
'3',
35 $this->fail(
'Expected exception not thrown' );
36 }
catch ( RuntimeException $ex ) {
38 'Attempting to add element setValue=99, existing value is 1',
46 $this->fail(
'Expected exception not thrown' );
47 }
catch ( RuntimeException $ex ) {
49 'Attempting to set content element as setContentValue2 when setContentValue ' .
50 'is already set as the content element',
57 $this->assertSame(
'99', $arr[
'setValue'] );
62 $arr = [
'foo' => 1,
'bar' => 1 ];
68 $this->assertSame( [ 0,
'top',
'foo',
'bar',
'bottom' ], array_keys( $arr ) );
73 $this->assertSame( [
'sub' => [
'foo' => 1,
'bar' => 1 ] ], $arr );
77 $this->fail(
'Expected exception not thrown' );
78 }
catch ( RuntimeException $ex ) {
80 'Conflicting keys (foo) when attempting to merge element sub',
87 $title = Title::newFromText(
"MediaWiki:Foobar" );
94 'title' => (
string)$title,
101 $this->fail(
'Expected exception not thrown' );
102 }
catch ( InvalidArgumentException $ex ) {
104 'Cannot add resource(stream) to ApiResult',
111 $this->fail(
'Expected exception not thrown' );
112 }
catch ( InvalidArgumentException $ex ) {
114 'Cannot add resource(stream) to ApiResult',
122 $this->fail(
'Expected exception not thrown' );
123 }
catch ( InvalidArgumentException $ex ) {
125 'Cannot add resource(stream) to ApiResult',
133 $this->fail(
'Expected exception not thrown' );
134 }
catch ( InvalidArgumentException $ex ) {
136 'Cannot add resource(stream) to ApiResult',
145 $this->fail(
'Expected exception not thrown' );
146 }
catch ( InvalidArgumentException $ex ) {
148 'Cannot add non-finite floats to ApiResult',
155 $this->fail(
'Expected exception not thrown' );
156 }
catch ( InvalidArgumentException $ex ) {
158 'Cannot add non-finite floats to ApiResult',
165 $this->fail(
'Expected exception not thrown' );
166 }
catch ( InvalidArgumentException $ex ) {
168 'Cannot add non-finite floats to ApiResult',
175 $this->fail(
'Expected exception not thrown' );
176 }
catch ( InvalidArgumentException $ex ) {
178 'Cannot add non-finite floats to ApiResult',
188 $this->fail(
'Expected exception not thrown' );
189 }
catch ( InvalidArgumentException $ex ) {
191 'Cannot add non-finite floats to ApiResult',
199 $result2->addValue(
null,
'foo',
'bar' );
215 'foo' =>
"foo\xef\xbf\xbdbar",
218 0 =>
"foo\xef\xbf\xbdbar",
240 $result->addValue(
null,
'setValue',
'1' );
242 $result->addValue(
null,
null,
'unnamed 1' );
243 $result->addValue(
null,
null,
'unnamed 2' );
245 $result->addValue(
null,
'deleteValue',
'2' );
246 $result->removeValue(
null,
'deleteValue' );
248 $result->addValue( [
'a',
'b' ],
'deleteValue',
'3' );
249 $result->removeValue( [
'a',
'b',
'deleteValue' ],
null,
'3' );
251 $result->addContentValue(
null,
'setContentValue',
'3' );
257 'a' => [
'b' => [] ],
258 'setContentValue' =>
'3',
261 ], $result->getResultData() );
262 $this->assertSame( 20, $result->getSize() );
265 $result->addValue(
null,
'setValue',
'99' );
266 $this->fail(
'Expected exception not thrown' );
267 }
catch ( RuntimeException $ex ) {
269 'Attempting to add element setValue=99, existing value is 1',
276 $result->addContentValue(
null,
'setContentValue2',
'99' );
277 $this->fail(
'Expected exception not thrown' );
278 }
catch ( RuntimeException $ex ) {
280 'Attempting to set content element as setContentValue2 when setContentValue ' .
281 'is already set as the content element',
288 $this->assertSame(
'99', $result->getResultData( [
'setValue' ] ) );
291 $this->assertSame(
'setContentValue2',
297 ], $result->getResultData() );
298 $this->assertSame( 0, $result->getSize() );
300 $result->addValue(
null,
'foo', 1 );
301 $result->addValue(
null,
'bar', 1 );
304 $result->addValue(
null,
'bottom',
'2' );
308 array_keys( $result->getResultData() ) );
311 $result->addValue(
null,
'foo', [
'bar' => 1 ] );
313 $result->addValue( [
'foo',
'bottom' ],
'x', 2 );
314 $this->assertSame( [
'top',
'bar',
'bottom' ],
315 array_keys( $result->getResultData( [
'foo' ] ) ) );
318 $result->addValue(
null,
'sub', [
'foo' => 1 ] );
319 $result->addValue(
null,
'sub', [
'bar' => 1 ] );
321 'sub' => [
'foo' => 1,
'bar' => 1 ],
323 ], $result->getResultData() );
326 $result->addValue(
null,
'sub', [
'foo' => 2,
'baz' => 2 ] );
327 $this->fail(
'Expected exception not thrown' );
328 }
catch ( RuntimeException $ex ) {
330 'Conflicting keys (foo) when attempting to merge element sub',
337 $title = Title::newFromText(
"MediaWiki:Foobar" );
341 $result->addValue(
null,
'title', $title );
342 $result->addValue(
null,
'obj', $obj );
344 'title' => (
string)$title,
347 ], $result->getResultData() );
351 $result->addValue(
null,
'file', $fh );
352 $this->fail(
'Expected exception not thrown' );
353 }
catch ( InvalidArgumentException $ex ) {
355 'Cannot add resource(stream) to ApiResult',
361 $result->addValue(
null,
null, $fh );
362 $this->fail(
'Expected exception not thrown' );
363 }
catch ( InvalidArgumentException $ex ) {
365 'Cannot add resource(stream) to ApiResult',
372 $result->addValue(
null,
'sub', $obj );
373 $this->fail(
'Expected exception not thrown' );
374 }
catch ( InvalidArgumentException $ex ) {
376 'Cannot add resource(stream) to ApiResult',
383 $result->addValue(
null,
null, $obj );
384 $this->fail(
'Expected exception not thrown' );
385 }
catch ( InvalidArgumentException $ex ) {
387 'Cannot add resource(stream) to ApiResult',
395 $result->addValue(
null,
'inf', INF );
396 $this->fail(
'Expected exception not thrown' );
397 }
catch ( InvalidArgumentException $ex ) {
399 'Cannot add non-finite floats to ApiResult',
405 $result->addValue(
null,
null, INF );
406 $this->fail(
'Expected exception not thrown' );
407 }
catch ( InvalidArgumentException $ex ) {
409 'Cannot add non-finite floats to ApiResult',
415 $result->addValue(
null,
'nan', NAN );
416 $this->fail(
'Expected exception not thrown' );
417 }
catch ( InvalidArgumentException $ex ) {
419 'Cannot add non-finite floats to ApiResult',
425 $result->addValue(
null,
null, NAN );
426 $this->fail(
'Expected exception not thrown' );
427 }
catch ( InvalidArgumentException $ex ) {
429 'Cannot add non-finite floats to ApiResult',
439 $this->fail(
'Expected exception not thrown' );
440 }
catch ( InvalidArgumentException $ex ) {
442 'Cannot add non-finite floats to ApiResult',
449 $result->addParsedLimit(
'foo', 12 );
451 'limits' => [
'foo' => 12 ],
453 ], $result->getResultData() );
454 $result->addParsedLimit(
'foo', 13 );
456 'limits' => [
'foo' => 13 ],
458 ], $result->getResultData() );
459 $this->assertSame(
null, $result->getResultData( [
'foo',
'bar',
'baz' ] ) );
460 $this->assertSame( 13, $result->getResultData( [
'limits',
'foo' ] ) );
462 $result->getResultData( [
'limits',
'foo',
'bar' ] );
463 $this->fail(
'Expected exception not thrown' );
464 }
catch ( InvalidArgumentException $ex ) {
466 'Path limits.foo is not an array',
474 $obj = [
'attr' =>
'12345' ];
476 $this->assertTrue( $result->addValue(
null,
'foo', $obj ) );
477 $this->assertSame( 15, $result->getSize() );
480 $formatter =
new ApiErrorFormatter( $result, Language::factory(
'en' ),
'none',
false );
481 $result->setErrorFormatter( $formatter );
482 $this->assertFalse( $result->addValue(
null,
'foo',
'12345678901' ) );
484 $this->assertSame( 0, $result->getSize() );
486 $this->assertTrue( $result->addValue(
null,
'foo',
'1234567890' ) );
487 $this->assertFalse( $result->addValue(
null,
'foo',
'1' ) );
488 $result->removeValue(
null,
'foo' );
489 $this->assertTrue( $result->addValue(
null,
'foo',
'1' ) );
493 $obj->foobar =
'foobaz';
494 $this->assertTrue( $result->addValue(
null,
'foo', $obj ) );
495 $this->assertSame( 2, $result->getSize() );
499 $result2->addValue(
null,
'foo',
'bar' );
500 $result->addValue(
null,
'baz', $result2 );
507 ], $result->getResultData() );
510 $result->addValue(
null,
'foo',
"foo\x80bar" );
511 $result->addValue(
null,
'bar',
"a\xcc\x81" );
512 $result->addValue(
null,
'baz', 74 );
513 $result->addValue(
null,
null,
"foo\x80bar" );
514 $result->addValue(
null,
null,
"a\xcc\x81" );
516 'foo' =>
"foo\xef\xbf\xbdbar",
519 0 =>
"foo\xef\xbf\xbdbar",
522 ], $result->getResultData() );
528 $result->addValue( $arr,
'foo', $obj );
535 ], $result->getResultData() );
542 $arr = [
'foo' => [
'bar' => [] ] ];
544 $result->addValue(
null,
'foo', [
'bar' => [] ] );
571 $this->assertSame( $expect, $arr );
573 $result->addSubelementsList(
null,
'foo' );
574 $result->addSubelementsList(
null, [
'bar',
'baz' ] );
575 $result->removeSubelementsList(
null,
'baz' );
576 $result->addIndexedTagNameRecursive(
null,
'ritn' );
577 $result->addIndexedTagName(
null,
'itn' );
578 $result->addPreserveKeysList(
null,
'foo' );
579 $result->addPreserveKeysList(
null, [
'bar',
'baz' ] );
580 $result->removePreserveKeysList(
null,
'baz' );
581 $result->addArrayTypeRecursive(
null,
'default' );
582 $result->addArrayType(
null,
'array' );
583 $this->assertEquals( $expect, $result->getResultData() );
585 $arr = [
'foo' => [
'bar' => [] ] ];
600 $this->assertSame( $expect, $arr );
609 'bar' => [
'_dummy' =>
'foobaz' ],
610 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
612 '_dummy' =>
'foobaz',
615 'bar' => [
'_dummy' =>
'foobaz' ],
616 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
618 '_dummy' =>
'foobaz',
624 '_dummy' =>
'foobaz',
625 '_dummy2' =>
'foobaz!',
627 $this->assertEquals( [
630 'bar2' => (
object)[],
635 'bar2' => (
object)[],
638 '_dummy2' =>
'foobaz!',
643 $this->assertEquals( [
645 'bar' => [
'_dummy' =>
'foobaz' ],
646 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
648 '_dummy' =>
'foobaz',
651 'bar' => [
'_dummy' =>
'foobaz' ],
652 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
654 '_dummy' =>
'foobaz',
656 '_dummy2' =>
'foobaz!',
657 ], $data,
'ApiResult::stripMetadataNonRecursive ($data)' );
658 $this->assertEquals( [
663 '_dummy' =>
'foobaz',
664 ], $metadata,
'ApiResult::stripMetadataNonRecursive ($metadata)' );
668 $this->assertEquals( (
object)[
670 'bar' => [
'_dummy' =>
'foobaz' ],
671 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
673 '_dummy' =>
'foobaz',
676 'bar' => [
'_dummy' =>
'foobaz' ],
677 'bar2' => (
object)[
'_dummy' =>
'foobaz' ],
679 '_dummy' =>
'foobaz',
681 '_dummy2' =>
'foobaz!',
682 ], $data,
'ApiResult::stripMetadataNonRecursive on object ($data)' );
683 $this->assertEquals( [
688 '_dummy' =>
'foobaz',
689 ], $metadata,
'ApiResult::stripMetadataNonRecursive on object ($metadata)' );
702 $result->addValue(
null,
'test',
$input );
704 if ( $expect instanceof Exception ) {
706 $output = $result->getResultData(
'test', $transforms );
707 $this->fail(
'Expected exception not thrown', $label );
708 }
catch ( Exception $ex ) {
709 $this->assertEquals( $ex, $expect, $label );
712 $output = $result->getResultData(
'test', $transforms );
713 $this->assertEquals( $expect,
$output, $label );
718 $kvp =
function ( $keyKey, $key, $valKey,
$value ) {
728 'defaultArray' => [ 2 =>
'a', 0 =>
'b', 1 =>
'c' ],
729 'defaultAssoc' => [
'x' =>
'a', 1 =>
'b', 0 =>
'c' ],
730 'defaultAssoc2' => [ 2 =>
'a', 3 =>
'b', 0 =>
'c' ],
736 'BCkvp' => [
'x' =>
'a',
'y' =>
'b',
740 'kvpmerge' => [
'x' =>
'a',
'y' => [
'b' ],
'z' => [
'c' =>
'd' ],
744 'emptyDefault' => [
'_dummy' => 1 ],
751 'bar' => [
'_dummy' =>
'foobaz' ],
759 '_dummy' =>
'foobaz',
765 '_dummy' =>
'foobaz',
766 '_dummy2' =>
'foobaz!',
788 'BC: META_BC_SUBELEMENTS',
820 'foo' =>
'foo value',
821 'bar' =>
'bar value',
822 '_baz' =>
'baz value',
829 $kvp(
'key',
'foo',
'*',
'foo value' ),
830 $kvp(
'key',
'bar',
'*',
'bar value' ),
831 $kvp(
'key',
'_baz',
'*',
'baz value' ),
858 'BC: BCkvp exception',
863 new UnexpectedValueException(
864 'Type "BCkvp" used without setting ApiResult::META_KVP_KEY_NAME metadata item'
868 'BC: nobool, no*, nosub',
872 'content' =>
'content',
879 'foo' =>
'foo value',
880 'bar' =>
'bar value',
881 '_baz' =>
'baz value',
887 [
'BC' => [
'nobool',
'no*',
'nosub' ] ],
891 'content' =>
'content',
896 $kvp(
'key',
'foo',
'*',
'foo value' ),
897 $kvp(
'key',
'bar',
'*',
'bar value' ),
898 $kvp(
'key',
'_baz',
'*',
'baz value' ),
909 'Types: Normal transform',
920 'kvp' => [
'x' =>
'a',
'y' =>
'b',
924 'BCkvp' => [
'x' =>
'a',
'y' =>
'b',
943 'Types: AssocAsObject',
945 [
'Types' => [
'AssocAsObject' =>
true ] ],
948 'defaultAssoc' => (
object)[
'x' =>
'a',
951 'defaultAssoc2' => (
object)[ 2 =>
'a', 3 =>
'b',
958 'kvp' => (
object)[
'x' =>
'a',
'y' =>
'b',
962 'BCkvp' => (
object)[
'x' =>
'a',
'y' =>
'b',
966 'kvpmerge' => (
object)[
983 [
'Types' => [
'ArmorKVP' =>
'name' ] ],
993 $kvp(
'name',
'x',
'value',
'a' ),
994 $kvp(
'name',
'y',
'value',
'b' ),
999 $kvp(
'key',
'x',
'value',
'a' ),
1000 $kvp(
'key',
'y',
'value',
'b' ),
1005 $kvp(
'name',
'x',
'value',
'a' ),
1024 'Types: ArmorKVP + BC',
1026 [
'BC' => [],
'Types' => [
'ArmorKVP' =>
'name' ] ],
1036 $kvp(
'name',
'x',
'*',
'a' ),
1037 $kvp(
'name',
'y',
'*',
'b' ),
1042 $kvp(
'key',
'x',
'*',
'a' ),
1043 $kvp(
'key',
'y',
'*',
'b' ),
1048 $kvp(
'name',
'x',
'*',
'a' ),
1066 'Types: ArmorKVP + AssocAsObject',
1068 [
'Types' => [
'ArmorKVP' =>
'name',
'AssocAsObject' =>
true ] ],
1071 'defaultAssoc' => (
object)[
'x' =>
'a', 1 =>
'b',
1074 'defaultAssoc2' => (
object)[ 2 =>
'a', 3 =>
'b',
1082 (
object)$kvp(
'name',
'x',
'value',
'a' ),
1083 (
object)$kvp(
'name',
'y',
'value',
'b' ),
1088 (
object)$kvp(
'key',
'x',
'value',
'a' ),
1089 (
object)$kvp(
'key',
'y',
'value',
'b' ),
1094 (
object)$kvp(
'name',
'x',
'value',
'a' ),
1113 'Types: BCkvp exception',
1118 new UnexpectedValueException(
1119 'Type "BCkvp" used without setting ApiResult::META_KVP_KEY_NAME metadata item'
1124 'Strip: With ArmorKVP + AssocAsObject transforms',
1126 [
'Types' => [
'ArmorKVP' =>
'name',
'AssocAsObject' =>
true ],
'Strip' =>
'all' ],
1128 'defaultArray' => [
'b',
'c',
'a' ],
1129 'defaultAssoc' => (
object)[
'x' =>
'a', 1 =>
'b', 0 =>
'c' ],
1130 'defaultAssoc2' => (
object)[ 2 =>
'a', 3 =>
'b', 0 =>
'c' ],
1131 'array' => [
'a',
'c',
'b' ],
1132 'BCarray' => [
'a',
'c',
'b' ],
1133 'BCassoc' => (
object)[
'a',
'b',
'c' ],
1134 'assoc' => (
object)[ 2 =>
'a', 0 =>
'b', 1 =>
'c' ],
1136 (
object)[
'name' =>
'x',
'value' =>
'a' ],
1137 (
object)[
'name' =>
'y',
'value' =>
'b' ],
1138 (
object)[
'name' =>
'z',
'value' => [
'c' ] ],
1141 (
object)[
'key' =>
'x',
'value' =>
'a' ],
1142 (
object)[
'key' =>
'y',
'value' =>
'b' ],
1145 (
object)[
'name' =>
'x',
'value' =>
'a' ],
1146 (
object)[
'name' =>
'y',
'value' => [
'b' ] ],
1147 (
object)[
'name' =>
'z',
'c' =>
'd' ],
1149 'emptyDefault' => [],
1150 'emptyAssoc' => (
object)[],
1158 [
'Strip' =>
'all' ],
1165 '_dummy2' =>
'foobaz!',
1171 [
'Strip' =>
'base' ],
1174 'bar' => [
'_dummy' =>
'foobaz' ],
1182 '_dummy' =>
'foobaz',
1184 '_dummy2' =>
'foobaz!',
1190 [
'Strip' =>
'bc' ],
1200 '_dummy2' =>
'foobaz!',
1218 'Custom' => [ $this,
'customTransform' ],
1226 'baz' => [
'a',
'b' ],
1227 '_dummy2' =>
'_DUMMY2',
1228 '_dummy3' =>
'_DUMMY3',
1242 if ( isset( $metadata[
'_added'] ) ) {
1247 foreach ( $data as $k => $v ) {
1248 $data[$k] = strtoupper( $k );
1250 $data[
'baz'] = [
'_added' => 1,
'z' =>
'b',
'y' =>
'a' ];
1263 'sequential_numeric_keys' => [
'a',
'b',
'c' ],
1264 'non_sequential_numeric_keys' => [
'a',
'b', 4 =>
'c' ],
1269 'object_sequential_keys' => (
object)[
'a',
'b',
'c' ],
1270 '_type' =>
"should be overwritten in result",
1272 $this->assertSame( [
1277 'sequential_numeric_keys',
'non_sequential_numeric_keys',
1278 'string_keys',
'object_sequential_keys'
1285 'sequential_numeric_keys' => [
1293 'non_sequential_numeric_keys' => [
1312 'object_sequential_keys' => [
1328 $this->assertSame( [
1336 $this->assertSame(
'Ok', $arr[
'foo'] );
1340 $this->assertSame(
'Ok', $arr[
'foo'] );
1347 $this->fail(
'Expected exception not thrown' );
1348 }
catch ( UnexpectedValueException $ex ) {
1350 'ApiResultTestSerializableObject::serializeForApiResult() ' .
1351 'returned an object of class ApiResultTestStringifiableObject',
1353 'Expected exception'
1360 $this->fail(
'Expected exception not thrown' );
1361 }
catch ( UnexpectedValueException $ex ) {
1363 'ApiResultTestSerializableObject::serializeForApiResult() ' .
1364 'returned an invalid value: Cannot add non-finite floats to ApiResult',
1366 'Expected exception'
1377 $this->assertSame( [
testAddMetadataToResultVars()
ApiResult.
testInstanceDataMethods()
ApiResult.
testUtilityFunctions()
ApiResult.
testTransformations( $label, $input, $transforms, $expect)
ApiResult provideTransformations.
testObjectSerialization()
testStaticDataMethods()
ApiResult.
customTransform(&$data, &$metadata)
Custom transformer for testTransformations.
This class represents the result of the API operations.
static unsetSubelementsList(array &$arr, $names)
Causes the elements with the specified names to be output as attributes (when possible) rather than a...
static unsetPreserveKeysList(array &$arr, $names)
Don't preserve specified keys.
const META_TYPE
Key for the 'type' metadata item.
static stripMetadataNonRecursive( $data, &$metadata=null)
Remove metadata keys from a data array or object, non-recursive.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
static addMetadataToResultVars( $vars, $forceHash=true)
Add the correct metadata to an array of vars we want to export through the API.
static setValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name.
const META_SUBELEMENTS
Key for the 'subelements' metadata item.
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
const META_PRESERVE_KEYS
Key for the 'preserve keys' metadata item.
const NO_SIZE_CHECK
For addValue() and similar functions, do not check size while adding a value Don't use this unless yo...
static unsetValue(array &$arr, $name)
Remove an output value to the array by name.
static setPreserveKeysList(array &$arr, $names)
Preserve specified keys.
static stripMetadata( $data)
Recursively remove metadata keys from a data array or object.
const META_CONTENT
Key for the 'content' metadata item.
const OVERRIDE
Override existing value in addValue(), setValue(), and similar functions.
static setSubelementsList(array &$arr, $names)
Causes the elements with the specified names to be output as subelements rather than attributes.
static setArrayTypeRecursive(array &$arr, $type, $kvpKeyName=null)
Set the array data type recursively.
const META_KVP_KEY_NAME
Key for the metadata item whose value specifies the name used for the kvp key in the alternative outp...
const ADD_ON_TOP
For addValue(), setValue() and similar functions, if the value does not exist, add it as the first el...
const META_BC_SUBELEMENTS
Key for the 'BC subelements' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
const META_INDEXED_TAG_NAME
Key for the 'indexed tag name' metadata item.
const META_KVP_MERGE
Key for the metadata item that indicates that the KVP key should be added into an assoc value,...
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
static setIndexedTagNameRecursive(array &$arr, $tag)
Set indexed tag name on $arr and all subarrays.
const NO_VALIDATE
For addValue(), setValue() and similar functions, do not validate data.
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
if(is_array($mode)) switch( $mode) $input