MediaWiki REL1_31
ExtensionProcessorTest.php
Go to the documentation of this file.
1<?php
2
3use Wikimedia\TestingAccessWrapper;
4
9
10 private $dir, $dirname;
11
12 public function setUp() {
13 parent::setUp();
14 $this->dir = __DIR__ . '/FooBar/extension.json';
15 $this->dirname = dirname( $this->dir );
16 }
17
23 public static $default = [
24 'name' => 'FooBar',
25 ];
26
27 public function testExtractInfo() {
28 // Test that attributes that begin with @ are ignored
29 $processor = new ExtensionProcessor();
30 $processor->extractInfo( $this->dir, self::$default + [
31 '@metadata' => [ 'foobarbaz' ],
32 'AnAttribute' => [ 'omg' ],
33 'AutoloadClasses' => [ 'FooBar' => 'includes/FooBar.php' ],
34 'SpecialPages' => [ 'Foo' => 'SpecialFoo' ],
35 'callback' => 'FooBar::onRegistration',
36 ], 1 );
37
38 $extracted = $processor->getExtractedInfo();
39 $attributes = $extracted['attributes'];
40 $this->assertArrayHasKey( 'AnAttribute', $attributes );
41 $this->assertArrayNotHasKey( '@metadata', $attributes );
42 $this->assertArrayNotHasKey( 'AutoloadClasses', $attributes );
43 $this->assertSame(
44 [ 'FooBar' => 'FooBar::onRegistration' ],
45 $extracted['callbacks']
46 );
47 $this->assertSame(
48 [ 'Foo' => 'SpecialFoo' ],
49 $extracted['globals']['wgSpecialPages']
50 );
51 }
52
53 public function testExtractNamespaces() {
54 // Test that namespace IDs can be overwritten
55 if ( !defined( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X' ) ) {
56 define( 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X', 123456 );
57 }
58
59 $processor = new ExtensionProcessor();
60 $processor->extractInfo( $this->dir, self::$default + [
61 'namespaces' => [
62 [
63 'id' => 332200,
64 'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
65 'name' => 'Test_A',
66 'defaultcontentmodel' => 'TestModel',
67 'gender' => [
68 'male' => 'Male test',
69 'female' => 'Female test',
70 ],
71 'subpages' => true,
72 'content' => true,
73 'protection' => 'userright',
74 ],
75 [ // Test_X will use ID 123456 not 334400
76 'id' => 334400,
77 'constant' => 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
78 'name' => 'Test_X',
79 'defaultcontentmodel' => 'TestModel'
80 ],
81 ]
82 ], 1 );
83
84 $extracted = $processor->getExtractedInfo();
85
86 $this->assertArrayHasKey(
87 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A',
88 $extracted['defines']
89 );
90 $this->assertArrayNotHasKey(
91 'MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_X',
92 $extracted['defines']
93 );
94
95 $this->assertSame(
96 $extracted['defines']['MW_EXTENSION_PROCESSOR_TEST_EXTRACT_INFO_A'],
97 332200
98 );
99
100 $this->assertArrayHasKey( 'ExtensionNamespaces', $extracted['attributes'] );
101 $this->assertArrayHasKey( 123456, $extracted['attributes']['ExtensionNamespaces'] );
102 $this->assertArrayHasKey( 332200, $extracted['attributes']['ExtensionNamespaces'] );
103 $this->assertArrayNotHasKey( 334400, $extracted['attributes']['ExtensionNamespaces'] );
104
105 $this->assertSame( 'Test_X', $extracted['attributes']['ExtensionNamespaces'][123456] );
106 $this->assertSame( 'Test_A', $extracted['attributes']['ExtensionNamespaces'][332200] );
107 $this->assertSame(
108 [ 'male' => 'Male test', 'female' => 'Female test' ],
109 $extracted['globals']['wgExtraGenderNamespaces'][332200]
110 );
111 // A has subpages, X does not
112 $this->assertTrue( $extracted['globals']['wgNamespacesWithSubpages'][332200] );
113 $this->assertArrayNotHasKey( 123456, $extracted['globals']['wgNamespacesWithSubpages'] );
114 }
115
116 public static function provideRegisterHooks() {
117 $merge = [ ExtensionRegistry::MERGE_STRATEGY => 'array_merge_recursive' ];
118 // Format:
119 // Current $wgHooks
120 // Content in extension.json
121 // Expected value of $wgHooks
122 return [
123 // No hooks
124 [
125 [],
127 $merge,
128 ],
129 // No current hooks, adding one for "FooBaz" in string format
130 [
131 [],
132 [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
133 [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
134 ],
135 // Hook for "FooBaz", adding another one
136 [
137 [ 'FooBaz' => [ 'PriorCallback' ] ],
138 [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
139 [ 'FooBaz' => [ 'PriorCallback', 'FooBazCallback' ] ] + $merge,
140 ],
141 // No current hooks, adding one for "FooBaz" in verbose array format
142 [
143 [],
144 [ 'Hooks' => [ 'FooBaz' => [ 'FooBazCallback' ] ] ] + self::$default,
145 [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
146 ],
147 // Hook for "BarBaz", adding one for "FooBaz"
148 [
149 [ 'BarBaz' => [ 'BarBazCallback' ] ],
150 [ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
151 [
152 'BarBaz' => [ 'BarBazCallback' ],
153 'FooBaz' => [ 'FooBazCallback' ],
154 ] + $merge,
155 ],
156 // Callbacks for FooBaz wrapped in an array
157 [
158 [],
159 [ 'Hooks' => [ 'FooBaz' => [ 'Callback1' ] ] ] + self::$default,
160 [
161 'FooBaz' => [ 'Callback1' ],
162 ] + $merge,
163 ],
164 // Multiple callbacks for FooBaz hook
165 [
166 [],
167 [ 'Hooks' => [ 'FooBaz' => [ 'Callback1', 'Callback2' ] ] ] + self::$default,
168 [
169 'FooBaz' => [ 'Callback1', 'Callback2' ],
170 ] + $merge,
171 ],
172 ];
173 }
174
178 public function testRegisterHooks( $pre, $info, $expected ) {
179 $processor = new MockExtensionProcessor( [ 'wgHooks' => $pre ] );
180 $processor->extractInfo( $this->dir, $info, 1 );
181 $extracted = $processor->getExtractedInfo();
182 $this->assertEquals( $expected, $extracted['globals']['wgHooks'] );
183 }
184
185 public function testExtractConfig1() {
186 $processor = new ExtensionProcessor;
187 $info = [
188 'config' => [
189 'Bar' => 'somevalue',
190 'Foo' => 10,
191 '@IGNORED' => 'yes',
192 ],
193 ] + self::$default;
194 $info2 = [
195 'config' => [
196 '_prefix' => 'eg',
197 'Bar' => 'somevalue'
198 ],
199 'name' => 'FooBar2',
200 ];
201 $processor->extractInfo( $this->dir, $info, 1 );
202 $processor->extractInfo( $this->dir, $info2, 1 );
203 $extracted = $processor->getExtractedInfo();
204 $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
205 $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
206 $this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
207 // Custom prefix:
208 $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
209 }
210
211 public function testExtractConfig2() {
212 $processor = new ExtensionProcessor;
213 $info = [
214 'config' => [
215 'Bar' => [ 'value' => 'somevalue' ],
216 'Foo' => [ 'value' => 10 ],
217 'Path' => [ 'value' => 'foo.txt', 'path' => true ],
218 'Namespaces' => [
219 'value' => [
220 '10' => true,
221 '12' => false,
222 ],
223 'merge_strategy' => 'array_plus',
224 ],
225 ],
226 ] + self::$default;
227 $info2 = [
228 'config' => [
229 'Bar' => [ 'value' => 'somevalue' ],
230 ],
231 'config_prefix' => 'eg',
232 'name' => 'FooBar2',
233 ];
234 $processor->extractInfo( $this->dir, $info, 2 );
235 $processor->extractInfo( $this->dir, $info2, 2 );
236 $extracted = $processor->getExtractedInfo();
237 $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
238 $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
239 $this->assertEquals( "{$this->dirname}/foo.txt", $extracted['globals']['wgPath'] );
240 // Custom prefix:
241 $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
242 $this->assertSame(
243 [ 10 => true, 12 => false, ExtensionRegistry::MERGE_STRATEGY => 'array_plus' ],
244 $extracted['globals']['wgNamespaces']
245 );
246 }
247
251 public function testDuplicateConfigKey1() {
252 $processor = new ExtensionProcessor;
253 $info = [
254 'config' => [
255 'Bar' => '',
256 ]
257 ] + self::$default;
258 $info2 = [
259 'config' => [
260 'Bar' => 'g',
261 ],
262 'name' => 'FooBar2',
263 ];
264 $processor->extractInfo( $this->dir, $info, 1 );
265 $processor->extractInfo( $this->dir, $info2, 1 );
266 }
267
271 public function testDuplicateConfigKey2() {
272 $processor = new ExtensionProcessor;
273 $info = [
274 'config' => [
275 'Bar' => [ 'value' => 'somevalue' ],
276 ]
277 ] + self::$default;
278 $info2 = [
279 'config' => [
280 'Bar' => [ 'value' => 'somevalue' ],
281 ],
282 'name' => 'FooBar2',
283 ];
284 $processor->extractInfo( $this->dir, $info, 2 );
285 $processor->extractInfo( $this->dir, $info2, 2 );
286 }
287
288 public static function provideExtractExtensionMessagesFiles() {
289 $dir = __DIR__ . '/FooBar/';
290 return [
291 [
292 [ 'ExtensionMessagesFiles' => [ 'FooBarAlias' => 'FooBar.alias.php' ] ],
293 [ 'wgExtensionMessagesFiles' => [ 'FooBarAlias' => $dir . 'FooBar.alias.php' ] ]
294 ],
295 [
296 [
297 'ExtensionMessagesFiles' => [
298 'FooBarAlias' => 'FooBar.alias.php',
299 'FooBarMagic' => 'FooBar.magic.i18n.php',
300 ],
301 ],
302 [
303 'wgExtensionMessagesFiles' => [
304 'FooBarAlias' => $dir . 'FooBar.alias.php',
305 'FooBarMagic' => $dir . 'FooBar.magic.i18n.php',
306 ],
307 ],
308 ],
309 ];
310 }
311
315 public function testExtractExtensionMessagesFiles( $input, $expected ) {
316 $processor = new ExtensionProcessor();
317 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
318 $out = $processor->getExtractedInfo();
319 foreach ( $expected as $key => $value ) {
320 $this->assertEquals( $value, $out['globals'][$key] );
321 }
322 }
323
324 public static function provideExtractMessagesDirs() {
325 $dir = __DIR__ . '/FooBar/';
326 return [
327 [
328 [ 'MessagesDirs' => [ 'VisualEditor' => 'i18n' ] ],
329 [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n' ] ] ]
330 ],
331 [
332 [ 'MessagesDirs' => [ 'VisualEditor' => [ 'i18n', 'foobar' ] ] ],
333 [ 'wgMessagesDirs' => [ 'VisualEditor' => [ $dir . 'i18n', $dir . 'foobar' ] ] ]
334 ],
335 ];
336 }
337
341 public function testExtractMessagesDirs( $input, $expected ) {
342 $processor = new ExtensionProcessor();
343 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
344 $out = $processor->getExtractedInfo();
345 foreach ( $expected as $key => $value ) {
346 $this->assertEquals( $value, $out['globals'][$key] );
347 }
348 }
349
350 public function testExtractCredits() {
351 $processor = new ExtensionProcessor();
352 $processor->extractInfo( $this->dir, self::$default, 1 );
353 $this->setExpectedException( Exception::class );
354 $processor->extractInfo( $this->dir, self::$default, 1 );
355 }
356
360 public function testExtractResourceLoaderModules( $input, $expected ) {
361 $processor = new ExtensionProcessor();
362 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
363 $out = $processor->getExtractedInfo();
364 foreach ( $expected as $key => $value ) {
365 $this->assertEquals( $value, $out['globals'][$key] );
366 }
367 }
368
369 public static function provideExtractResourceLoaderModules() {
370 $dir = __DIR__ . '/FooBar';
371 return [
372 // Generic module with localBasePath/remoteExtPath specified
373 [
374 // Input
375 [
376 'ResourceModules' => [
377 'test.foo' => [
378 'styles' => 'foobar.js',
379 'localBasePath' => '',
380 'remoteExtPath' => 'FooBar',
381 ],
382 ],
383 ],
384 // Expected
385 [
386 'wgResourceModules' => [
387 'test.foo' => [
388 'styles' => 'foobar.js',
389 'localBasePath' => $dir,
390 'remoteExtPath' => 'FooBar',
391 ],
392 ],
393 ],
394 ],
395 // ResourceFileModulePaths specified:
396 [
397 // Input
398 [
399 'ResourceFileModulePaths' => [
400 'localBasePath' => 'modules',
401 'remoteExtPath' => 'FooBar/modules',
402 ],
403 'ResourceModules' => [
404 // No paths
405 'test.foo' => [
406 'styles' => 'foo.js',
407 ],
408 // Different paths set
409 'test.bar' => [
410 'styles' => 'bar.js',
411 'localBasePath' => 'subdir',
412 'remoteExtPath' => 'FooBar/subdir',
413 ],
414 // Custom class with no paths set
415 'test.class' => [
416 'class' => 'FooBarModule',
417 'extra' => 'argument',
418 ],
419 // Custom class with a localBasePath
420 'test.class.with.path' => [
421 'class' => 'FooBarPathModule',
422 'extra' => 'argument',
423 'localBasePath' => '',
424 ]
425 ],
426 ],
427 // Expected
428 [
429 'wgResourceModules' => [
430 'test.foo' => [
431 'styles' => 'foo.js',
432 'localBasePath' => "$dir/modules",
433 'remoteExtPath' => 'FooBar/modules',
434 ],
435 'test.bar' => [
436 'styles' => 'bar.js',
437 'localBasePath' => "$dir/subdir",
438 'remoteExtPath' => 'FooBar/subdir',
439 ],
440 'test.class' => [
441 'class' => 'FooBarModule',
442 'extra' => 'argument',
443 'localBasePath' => "$dir/modules",
444 'remoteExtPath' => 'FooBar/modules',
445 ],
446 'test.class.with.path' => [
447 'class' => 'FooBarPathModule',
448 'extra' => 'argument',
449 'localBasePath' => $dir,
450 'remoteExtPath' => 'FooBar/modules',
451 ]
452 ],
453 ],
454 ],
455 // ResourceModuleSkinStyles with file module paths
456 [
457 // Input
458 [
459 'ResourceFileModulePaths' => [
460 'localBasePath' => '',
461 'remoteSkinPath' => 'FooBar',
462 ],
463 'ResourceModuleSkinStyles' => [
464 'foobar' => [
465 'test.foo' => 'foo.css',
466 ]
467 ],
468 ],
469 // Expected
470 [
471 'wgResourceModuleSkinStyles' => [
472 'foobar' => [
473 'test.foo' => 'foo.css',
474 'localBasePath' => $dir,
475 'remoteSkinPath' => 'FooBar',
476 ],
477 ],
478 ],
479 ],
480 // ResourceModuleSkinStyles with file module paths and an override
481 [
482 // Input
483 [
484 'ResourceFileModulePaths' => [
485 'localBasePath' => '',
486 'remoteSkinPath' => 'FooBar',
487 ],
488 'ResourceModuleSkinStyles' => [
489 'foobar' => [
490 'test.foo' => 'foo.css',
491 'remoteSkinPath' => 'BarFoo'
492 ],
493 ],
494 ],
495 // Expected
496 [
497 'wgResourceModuleSkinStyles' => [
498 'foobar' => [
499 'test.foo' => 'foo.css',
500 'localBasePath' => $dir,
501 'remoteSkinPath' => 'BarFoo',
502 ],
503 ],
504 ],
505 ],
506 ];
507 }
508
509 public static function provideSetToGlobal() {
510 return [
511 [
512 [ 'wgAPIModules', 'wgAvailableRights' ],
513 [],
514 [
515 'APIModules' => [ 'foobar' => 'ApiFooBar' ],
516 'AvailableRights' => [ 'foobar', 'unfoobar' ],
517 ],
518 [
519 'wgAPIModules' => [ 'foobar' => 'ApiFooBar' ],
520 'wgAvailableRights' => [ 'foobar', 'unfoobar' ],
521 ],
522 ],
523 [
524 [ 'wgAPIModules', 'wgAvailableRights' ],
525 [
526 'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz' ],
527 'wgAvailableRights' => [ 'barbaz' ]
528 ],
529 [
530 'APIModules' => [ 'foobar' => 'ApiFooBar' ],
531 'AvailableRights' => [ 'foobar', 'unfoobar' ],
532 ],
533 [
534 'wgAPIModules' => [ 'barbaz' => 'ApiBarBaz', 'foobar' => 'ApiFooBar' ],
535 'wgAvailableRights' => [ 'barbaz', 'foobar', 'unfoobar' ],
536 ],
537 ],
538 [
539 [ 'wgGroupPermissions' ],
540 [
541 'wgGroupPermissions' => [
542 'sysop' => [ 'delete' ]
543 ],
544 ],
545 [
546 'GroupPermissions' => [
547 'sysop' => [ 'undelete' ],
548 'user' => [ 'edit' ]
549 ],
550 ],
551 [
552 'wgGroupPermissions' => [
553 'sysop' => [ 'delete', 'undelete' ],
554 'user' => [ 'edit' ]
555 ],
556 ]
557 ]
558 ];
559 }
560
564 public function testExtractAttributes() {
565 $processor = new ExtensionProcessor();
566 // Load FooBar extension
567 $processor->extractInfo( $this->dir, [ 'name' => 'FooBar' ], 2 );
568 $processor->extractInfo(
569 $this->dir,
570 [
571 'name' => 'Baz',
572 'attributes' => [
573 // Loaded
574 'FooBar' => [
575 'Plugins' => [
576 'ext.baz.foobar',
577 ],
578 ],
579 // Not loaded
580 'FizzBuzz' => [
581 'MorePlugins' => [
582 'ext.baz.fizzbuzz',
583 ],
584 ],
585 ],
586 ],
587 2
588 );
589
590 $info = $processor->getExtractedInfo();
591 $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
592 $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
593 $this->assertArrayNotHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
594 }
595
599 public function testAttributes1() {
600 $processor = new ExtensionProcessor();
601 $processor->extractInfo(
602 $this->dir,
603 [
604 'name' => 'FooBar',
605 'FooBarPlugins' => [
606 'ext.baz.foobar',
607 ],
608 'FizzBuzzMorePlugins' => [
609 'ext.baz.fizzbuzz',
610 ],
611 ],
612 1
613 );
614 $processor->extractInfo(
615 $this->dir,
616 [
617 'name' => 'FooBar2',
618 'FizzBuzzMorePlugins' => [
619 'ext.bar.fizzbuzz',
620 ]
621 ],
622 1
623 );
624
625 $info = $processor->getExtractedInfo();
626 $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] );
627 $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] );
628 $this->assertArrayHasKey( 'FizzBuzzMorePlugins', $info['attributes'] );
629 $this->assertSame(
630 [ 'ext.baz.fizzbuzz', 'ext.bar.fizzbuzz' ],
631 $info['attributes']['FizzBuzzMorePlugins']
632 );
633 }
634
635 public function testAttributes1_notarray() {
636 $processor = new ExtensionProcessor();
637 $this->setExpectedException(
638 InvalidArgumentException::class,
639 "The value for 'FooBarPlugins' should be an array (from {$this->dir})"
640 );
641 $processor->extractInfo(
642 $this->dir,
643 [
644 'FooBarPlugins' => 'ext.baz.foobar',
645 ] + self::$default,
646 1
647 );
648 }
649
650 public function testExtractPathBasedGlobal() {
651 $processor = new ExtensionProcessor();
652 $processor->extractInfo(
653 $this->dir,
654 [
655 'ParserTestFiles' => [
656 'tests/parserTests.txt',
657 'tests/extraParserTests.txt',
658 ],
659 'ServiceWiringFiles' => [
660 'includes/ServiceWiring.php'
661 ],
662 ] + self::$default,
663 1
664 );
665 $globals = $processor->getExtractedInfo()['globals'];
666 $this->assertArrayHasKey( 'wgParserTestFiles', $globals );
667 $this->assertSame( [
668 "{$this->dirname}/tests/parserTests.txt",
669 "{$this->dirname}/tests/extraParserTests.txt"
670 ], $globals['wgParserTestFiles'] );
671 $this->assertArrayHasKey( 'wgServiceWiringFiles', $globals );
672 $this->assertSame( [
673 "{$this->dirname}/includes/ServiceWiring.php"
674 ], $globals['wgServiceWiringFiles'] );
675 }
676
677 public function testGetRequirements() {
678 $info = self::$default + [
679 'requires' => [
680 'MediaWiki' => '>= 1.25.0',
681 'extensions' => [
682 'Bar' => '*'
683 ]
684 ]
685 ];
686 $processor = new ExtensionProcessor();
687 $this->assertSame(
688 $info['requires'],
689 $processor->getRequirements( $info )
690 );
691 $this->assertSame(
692 [],
693 $processor->getRequirements( [] )
694 );
695 }
696
697 public function testGetExtraAutoloaderPaths() {
698 $processor = new ExtensionProcessor();
699 $this->assertSame(
700 [ "{$this->dirname}/vendor/autoload.php" ],
701 $processor->getExtraAutoloaderPaths( $this->dirname, [
702 'load_composer_autoloader' => true,
703 ] )
704 );
705 }
706
713 global $IP;
714 $globalSettings = TestingAccessWrapper::newFromClass(
715 ExtensionProcessor::class )->globalSettings;
716
718 $schema = FormatJson::decode(
719 file_get_contents( "$IP/docs/extension.schema.v$version.json" ),
720 true
721 );
722 $missing = [];
723 foreach ( $globalSettings as $global ) {
724 if ( !isset( $schema['properties'][$global] ) ) {
725 $missing[] = $global;
726 }
727 }
728
729 $this->assertEquals( [], $missing,
730 "The following global settings are not documented in docs/extension.schema.json" );
731 }
732}
733
739 public function __construct( $globals = [] ) {
741 }
742}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$IP
Definition WebStart.php:52
testDuplicateConfigKey2()
RuntimeException.
static array $default
'name' is absolutely required
testDuplicateConfigKey1()
RuntimeException.
testAttributes1()
Attributes under manifest_version 1.
testRegisterHooks( $pre, $info, $expected)
provideRegisterHooks
testExtractMessagesDirs( $input, $expected)
provideExtractMessagesDirs
testExtractExtensionMessagesFiles( $input, $expected)
provideExtractExtensionMessagesFiles
testExtractAttributes()
Attributes under manifest_version 2.
testExtractResourceLoaderModules( $input, $expected)
provideExtractResourceLoaderModules
testGlobalSettingsDocumentedInSchema()
Verify that extension.schema.json is in sync with ExtensionProcessor.
array $globals
Stuff that is going to be set to $GLOBALS.
extractInfo( $path, array $info, $version)
const MERGE_STRATEGY
Special key that defines the merge strategy.
const MANIFEST_VERSION
Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when chang...
Allow overriding the default value of $this->globals so we can test merging.
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
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 globals
Definition globals.txt:39
the array() calling protocol came about after MediaWiki 1.4rc1.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
Definition hooks.txt:1585
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:2006
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 $out
Definition hooks.txt:864
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:37
if(is_array($mode)) switch( $mode) $input