9 $this->dir = __DIR__ .
'/FooBar/extension.json';
27 $processor->extractInfo( $this->dir, self::$default + [
28 '@metadata' => [
'foobarbaz' ],
29 'AnAttribute' => [
'omg' ],
30 'AutoloadClasses' => [
'FooBar' =>
'includes/FooBar.php' ],
33 $extracted = $processor->getExtractedInfo();
34 $attributes = $extracted[
'attributes'];
35 $this->assertArrayHasKey(
'AnAttribute', $attributes );
36 $this->assertArrayNotHasKey(
'@metadata', $attributes );
37 $this->assertArrayNotHasKey(
'AutoloadClasses', $attributes );
56 [
'Hooks' => [
'FooBaz' =>
'FooBazCallback' ] ] + self::$default,
57 [
'FooBaz' => [
'FooBazCallback' ] ] + $merge,
61 [
'FooBaz' => [
'PriorCallback' ] ],
62 [
'Hooks' => [
'FooBaz' =>
'FooBazCallback' ] ] + self::$default,
63 [
'FooBaz' => [
'PriorCallback',
'FooBazCallback' ] ] + $merge,
68 [
'Hooks' => [
'FooBaz' => [
'FooBazCallback' ] ] ] + self::$default,
69 [
'FooBaz' => [
'FooBazCallback' ] ] + $merge,
73 [
'BarBaz' => [
'BarBazCallback' ] ],
74 [
'Hooks' => [
'FooBaz' =>
'FooBazCallback' ] ] + self::$default,
76 'BarBaz' => [
'BarBazCallback' ],
77 'FooBaz' => [
'FooBazCallback' ],
83 [
'Hooks' => [
'FooBaz' => [
'Callback1' ] ] ] + self::$default,
85 'FooBaz' => [
'Callback1' ],
91 [
'Hooks' => [
'FooBaz' => [
'Callback1',
'Callback2' ] ] ] + self::$default,
93 'FooBaz' => [
'Callback1',
'Callback2' ],
105 $processor->extractInfo( $this->dir, $info, 1 );
106 $extracted = $processor->getExtractedInfo();
107 $this->assertEquals( $expected, $extracted[
'globals'][
'wgHooks'] );
117 'Bar' =>
'somevalue',
130 $processor->extractInfo( $this->dir, $info2, 1 );
131 $extracted = $processor->getExtractedInfo();
132 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'wgBar'] );
133 $this->assertEquals( 10, $extracted[
'globals'][
'wgFoo'] );
134 $this->assertArrayNotHasKey(
'wg@IGNORED', $extracted[
'globals'] );
136 $this->assertEquals(
'somevalue', $extracted[
'globals'][
'egBar'] );
140 $dir = __DIR__ .
'/FooBar/';
143 [
'ExtensionMessagesFiles' => [
'FooBarAlias' =>
'FooBar.alias.php' ] ],
144 [
'wgExtensionMessagesFiles' => [
'FooBarAlias' =>
$dir .
'FooBar.alias.php' ] ]
148 'ExtensionMessagesFiles' => [
149 'FooBarAlias' =>
'FooBar.alias.php',
150 'FooBarMagic' =>
'FooBar.magic.i18n.php',
154 'wgExtensionMessagesFiles' => [
155 'FooBarAlias' =>
$dir .
'FooBar.alias.php',
156 'FooBarMagic' =>
$dir .
'FooBar.magic.i18n.php',
169 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
170 $out = $processor->getExtractedInfo();
171 foreach ( $expected
as $key =>
$value ) {
172 $this->assertEquals(
$value,
$out[
'globals'][$key] );
177 $dir = __DIR__ .
'/FooBar/';
180 [
'MessagesDirs' => [
'VisualEditor' =>
'i18n' ] ],
181 [
'wgMessagesDirs' => [
'VisualEditor' => [
$dir .
'i18n' ] ] ]
184 [
'MessagesDirs' => [
'VisualEditor' => [
'i18n',
'foobar' ] ] ],
185 [
'wgMessagesDirs' => [
'VisualEditor' => [
$dir .
'i18n',
$dir .
'foobar' ] ] ]
196 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
197 $out = $processor->getExtractedInfo();
198 foreach ( $expected
as $key =>
$value ) {
199 $this->assertEquals(
$value,
$out[
'globals'][$key] );
208 $processor->extractInfo( $this->dir, self::$default, 1 );
209 $this->setExpectedException(
'Exception' );
210 $processor->extractInfo( $this->dir, self::$default, 1 );
219 $processor->extractInfo( $this->dir, $input + self::$default, 1 );
220 $out = $processor->getExtractedInfo();
221 foreach ( $expected
as $key =>
$value ) {
222 $this->assertEquals(
$value,
$out[
'globals'][$key] );
227 $dir = __DIR__ .
'/FooBar';
233 'ResourceModules' => [
235 'styles' =>
'foobar.js',
236 'localBasePath' =>
'',
237 'remoteExtPath' =>
'FooBar',
243 'wgResourceModules' => [
245 'styles' =>
'foobar.js',
246 'localBasePath' =>
$dir,
247 'remoteExtPath' =>
'FooBar',
256 'ResourceFileModulePaths' => [
257 'localBasePath' =>
'',
258 'remoteExtPath' =>
'FooBar',
260 'ResourceModules' => [
263 'styles' =>
'foo.js',
267 'styles' =>
'bar.js',
268 'localBasePath' =>
'subdir',
269 'remoteExtPath' =>
'FooBar/subdir',
273 'class' =>
'FooBarModule',
274 'extra' =>
'argument',
277 'test.class.with.path' => [
278 'class' =>
'FooBarPathModule',
279 'extra' =>
'argument',
280 'localBasePath' =>
'',
286 'wgResourceModules' => [
288 'styles' =>
'foo.js',
289 'localBasePath' =>
$dir,
290 'remoteExtPath' =>
'FooBar',
293 'styles' =>
'bar.js',
294 'localBasePath' =>
"$dir/subdir",
295 'remoteExtPath' =>
'FooBar/subdir',
298 'class' =>
'FooBarModule',
299 'extra' =>
'argument',
300 'localBasePath' =>
$dir,
301 'remoteExtPath' =>
'FooBar',
303 'test.class.with.path' => [
304 'class' =>
'FooBarPathModule',
305 'extra' =>
'argument',
306 'localBasePath' =>
$dir,
307 'remoteExtPath' =>
'FooBar',
316 'ResourceFileModulePaths' => [
317 'localBasePath' =>
'',
318 'remoteSkinPath' =>
'FooBar',
320 'ResourceModuleSkinStyles' => [
322 'test.foo' =>
'foo.css',
328 'wgResourceModuleSkinStyles' => [
330 'test.foo' =>
'foo.css',
331 'localBasePath' =>
$dir,
332 'remoteSkinPath' =>
'FooBar',
341 'ResourceFileModulePaths' => [
342 'localBasePath' =>
'',
343 'remoteSkinPath' =>
'FooBar',
345 'ResourceModuleSkinStyles' => [
347 'test.foo' =>
'foo.css',
348 'remoteSkinPath' =>
'BarFoo'
354 'wgResourceModuleSkinStyles' => [
356 'test.foo' =>
'foo.css',
357 'localBasePath' =>
$dir,
358 'remoteSkinPath' =>
'BarFoo',
369 [
'wgAPIModules',
'wgAvailableRights' ],
372 'APIModules' => [
'foobar' =>
'ApiFooBar' ],
373 'AvailableRights' => [
'foobar',
'unfoobar' ],
376 'wgAPIModules' => [
'foobar' =>
'ApiFooBar' ],
377 'wgAvailableRights' => [
'foobar',
'unfoobar' ],
381 [
'wgAPIModules',
'wgAvailableRights' ],
383 'wgAPIModules' => [
'barbaz' =>
'ApiBarBaz' ],
384 'wgAvailableRights' => [
'barbaz' ]
387 'APIModules' => [
'foobar' =>
'ApiFooBar' ],
388 'AvailableRights' => [
'foobar',
'unfoobar' ],
391 'wgAPIModules' => [
'barbaz' =>
'ApiBarBaz',
'foobar' =>
'ApiFooBar' ],
392 'wgAvailableRights' => [
'barbaz',
'foobar',
'unfoobar' ],
396 [
'wgGroupPermissions' ],
398 'wgGroupPermissions' => [
399 'sysop' => [
'delete' ]
403 'GroupPermissions' => [
404 'sysop' => [
'undelete' ],
409 'wgGroupPermissions' => [
410 'sysop' => [
'delete',
'undelete' ],
424 file_get_contents(
"$IP/docs/extension.schema.json" ),
428 foreach ( $globalSettings
as $global ) {
429 if ( !isset( $schema[
'properties'][$global] ) ) {
430 $missing[] = $global;
434 $this->assertEquals( [], $missing,
435 "The following global settings are not documented in docs/extension.schema.json" );
array $globals
Stuff that is going to be set to $GLOBALS.
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
static array testExtractInfo()
ExtensionProcessor::extractInfo.
static array $default
'name' is absolutely required
testExtractCredits()
ExtensionProcessor::extractCredits.
static newFromClass($className)
Allow access to non-public static methods and properties of the class.
when a variable name is used in a it is silently declared as a new local masking the global
static provideExtractExtensionMessagesFiles()
const MERGE_STRATEGY
Special key that defines the merge strategy.
testExtractResourceLoaderModules($input, $expected)
ExtensionProcessor::extractResourceLoaderModules provideExtractResourceLoaderModules.
testExtractConfig()
ExtensionProcessor::extractConfig1.
static provideRegisterHooks()
extractInfo($path, array $info, $version)
Allow overriding the default value of $this->globals so we can test merging.
static provideExtractResourceLoaderModules()
testExtractExtensionMessagesFiles($input, $expected)
ExtensionProcessor::extractExtensionMessagesFiles provideExtractExtensionMessagesFiles.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
testRegisterHooks($pre, $info, $expected)
ExtensionProcessor::extractHooks provideRegisterHooks.
static provideSetToGlobal()
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
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
testExtractMessagesDirs($input, $expected)
ExtensionProcessor::extractMessagesDirs provideExtractMessagesDirs.
testGlobalSettingsDocumentedInSchema()
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 temp or archived zone 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
static provideExtractMessagesDirs()