19 'AuthManagerAutoConfig',
21 'CentralIdLookupProviders',
22 'ChangeCredentialsBlacklist',
26 'ExtensionEntryPointListFiles',
31 'GrantPermissionGroups',
35 'GroupsRemoveFromSelf',
51 'RemoveCredentialsBlacklist',
53 'ResourceLoaderSources',
64 protected const CORE_ATTRIBS = [
79 protected const MERGE_STRATEGIES = [
80 'wgAuthManagerAutoConfig' =>
'array_plus_2d',
81 'wgCapitalLinkOverrides' =>
'array_plus',
82 'wgExtraGenderNamespaces' =>
'array_plus',
83 'wgGrantPermissions' =>
'array_plus_2d',
84 'wgGroupPermissions' =>
'array_plus_2d',
85 'wgHooks' =>
'array_merge_recursive',
86 'wgNamespaceContentModels' =>
'array_plus',
87 'wgNamespaceProtection' =>
'array_plus',
88 'wgNamespacesWithSubpages' =>
'array_plus',
89 'wgPasswordPolicy' =>
'array_merge_recursive',
90 'wgRateLimits' =>
'array_plus_2d',
91 'wgRevokePermissions' =>
'array_plus_2d',
99 protected const CREDIT_ATTRIBS = [
117 protected const NOT_ATTRIBS = [
121 'load_composer_autoloader',
126 'ExtensionMessagesFiles',
128 'MessagePosterModule',
133 'ResourceFileModulePaths',
134 'ResourceModuleSkinStyles',
136 'ServiceWiringFiles',
147 'wgExtensionMessagesFiles' => [],
148 'wgMessagesDirs' => [],
193 $dir = dirname(
$path );
201 if ( isset( $info[
'ServiceWiringFiles'] ) ) {
203 'wgServiceWiringFiles',
205 $info[
'ServiceWiringFiles']
208 if ( isset( $info[
'ParserTestFiles'] ) ) {
212 $info[
'ParserTestFiles']
216 if ( isset( $info[
'callback'] ) ) {
217 $this->callbacks[$name] = $info[
'callback'];
222 if ( $version >= 2 ) {
230 if ( isset( $info[
'ParsoidModules'] ) ) {
231 foreach ( $info[
'ParsoidModules'] as &$module ) {
232 if ( is_string( $module ) ) {
233 $className = $module;
235 'class' => $className,
238 $module[
'name'] = $name;
242 if ( $version >= 2 ) {
246 foreach ( $info as $key => $val ) {
248 if ( in_array( $key, self::$globalSettings ) ) {
253 if ( $key[0] ===
'@' ) {
257 if ( $version >= 2 ) {
259 if ( in_array( $key, self::CORE_ATTRIBS ) ) {
264 if ( !in_array( $key, self::NOT_ATTRIBS )
265 && !in_array( $key, self::CREDIT_ATTRIBS )
279 if ( isset( $info[
'attributes'] ) ) {
280 foreach ( $info[
'attributes'] as $extName => $value ) {
288 foreach ( $this->globals as $key => $val ) {
289 if ( isset( self::MERGE_STRATEGIES[$key] ) ) {
290 $this->globals[$key][ExtensionRegistry::MERGE_STRATEGY] = self::MERGE_STRATEGIES[$key];
295 foreach ( $this->extAttributes as $extName => $value ) {
297 if ( isset( $this->credits[$extName] ) ) {
298 foreach ( $value as $attrName => $attrValue ) {
301 $extName . $attrName,
306 unset( $this->extAttributes[$extName] );
321 if ( !$includeDev || !isset( $info[
'dev-requires'] ) ) {
322 return $info[
'requires'] ?? [];
325 if ( !isset( $info[
'requires'] ) ) {
326 return $info[
'dev-requires'] ?? [];
336 $pick =
static function ( $a, $b ) {
339 } elseif ( $b ===
null ) {
346 $req = $info[
'requires'];
347 $dev = $info[
'dev-requires'];
348 if ( isset( $req[
'MediaWiki'] ) || isset( $dev[
'MediaWiki'] ) ) {
349 $merged[
'MediaWiki'] = $pick(
350 $req[
'MediaWiki'] ??
null,
351 $dev[
'MediaWiki'] ??
null
355 $platform = array_merge(
356 array_keys( $req[
'platform'] ?? [] ),
357 array_keys( $dev[
'platform'] ?? [] )
360 foreach ( $platform as $pkey ) {
361 if ( $pkey ===
'php' ) {
363 $req[
'platform'][
'php'] ??
null,
364 $dev[
'platform'][
'php'] ??
null
369 $value = $dev[
'platform'][$pkey] ?? $req[
'platform'][$pkey];
371 $merged[
'platform'][$pkey] = $value;
375 foreach ( [
'extensions',
'skins' ] as $thing ) {
376 $things = array_merge(
377 array_keys( $req[$thing] ?? [] ),
378 array_keys( $dev[$thing] ?? [] )
380 foreach ( $things as $name ) {
381 $merged[$thing][$name] = $pick(
382 $req[$thing][$name] ??
null,
383 $dev[$thing][$name] ??
null
403 array $hookHandlersAttr,
407 if ( isset( $callback[
'handler'] ) ) {
408 $handlerName = $callback[
'handler'];
409 $handlerDefinition = $hookHandlersAttr[$handlerName] ??
false;
410 if ( !$handlerDefinition ) {
411 throw new UnexpectedValueException(
412 "Missing handler definition for $name in HookHandlers attribute in $path"
415 $callback[
'handler'] = $handlerDefinition;
416 $callback[
'extensionPath'] =
$path;
417 $this->attributes[
'Hooks'][$name][] = $callback;
419 foreach ( $callback as $callable ) {
420 if ( is_array( $callable ) ) {
421 if ( isset( $callable[
'handler'] ) ) {
424 $this->globals[
'wgHooks'][$name][] = $callable;
426 } elseif ( is_string( $callable ) ) {
445 array $hookHandlersAttr,
449 if ( isset( $hookHandlersAttr[$callback] ) ) {
451 'handler' => $hookHandlersAttr[$callback],
452 'extensionPath' =>
$path
454 $this->attributes[
'Hooks'][$name][] = $handler;
456 $this->globals[
'wgHooks'][$name][] = $callback;
469 $extName = $info[
'name'];
470 if ( isset( $info[
'Hooks'] ) ) {
471 $hookHandlersAttr = [];
472 foreach ( $info[
'HookHandlers'] ?? [] as $name => $def ) {
473 $hookHandlersAttr[$name] = [
'name' =>
"$extName-$name" ] + $def;
475 foreach ( $info[
'Hooks'] as $name => $callback ) {
476 if ( is_string( $callback ) ) {
478 } elseif ( is_array( $callback ) ) {
483 if ( isset( $info[
'DeprecatedHooks'] ) ) {
484 $deprecatedHooks = [];
485 foreach ( $info[
'DeprecatedHooks'] as $name => $deprecatedHookInfo ) {
486 $deprecatedHookInfo += [
'component' => $extName ];
487 $deprecatedHooks[$name] = $deprecatedHookInfo;
489 if ( isset( $this->attributes[
'DeprecatedHooks'] ) ) {
490 $this->attributes[
'DeprecatedHooks'] += $deprecatedHooks;
492 $this->attributes[
'DeprecatedHooks'] = $deprecatedHooks;
503 if ( isset( $info[
'namespaces'] ) ) {
504 foreach ( $info[
'namespaces'] as $ns ) {
505 if ( defined( $ns[
'constant'] ) ) {
508 $id = constant( $ns[
'constant'] );
512 $this->defines[ $ns[
'constant'] ] = $id;
514 if ( !( isset( $ns[
'conditional'] ) && $ns[
'conditional'] ) ) {
516 $this->attributes[
'ExtensionNamespaces'][$id] = $ns[
'name'];
518 if ( isset( $ns[
'movable'] ) && !$ns[
'movable'] ) {
519 $this->attributes[
'ImmovableNamespaces'][] = $id;
521 if ( isset( $ns[
'gender'] ) ) {
522 $this->globals[
'wgExtraGenderNamespaces'][$id] = $ns[
'gender'];
524 if ( isset( $ns[
'subpages'] ) && $ns[
'subpages'] ) {
525 $this->globals[
'wgNamespacesWithSubpages'][$id] =
true;
527 if ( isset( $ns[
'content'] ) && $ns[
'content'] ) {
528 $this->globals[
'wgContentNamespaces'][] = $id;
530 if ( isset( $ns[
'defaultcontentmodel'] ) ) {
531 $this->globals[
'wgNamespaceContentModels'][$id] = $ns[
'defaultcontentmodel'];
533 if ( isset( $ns[
'protection'] ) ) {
534 $this->globals[
'wgNamespaceProtection'][$id] = $ns[
'protection'];
536 if ( isset( $ns[
'capitallinkoverride'] ) ) {
537 $this->globals[
'wgCapitalLinkOverrides'][$id] = $ns[
'capitallinkoverride'];
545 $defaultPaths = $info[
'ResourceFileModulePaths'] ??
false;
546 if ( isset( $defaultPaths[
'localBasePath'] ) ) {
547 if ( $defaultPaths[
'localBasePath'] ===
'' ) {
549 $defaultPaths[
'localBasePath'] = $dir;
551 $defaultPaths[
'localBasePath'] =
"$dir/{$defaultPaths['localBasePath']}";
555 foreach ( [
'ResourceModules',
'ResourceModuleSkinStyles',
'OOUIThemePaths' ] as $setting ) {
556 if ( isset( $info[$setting] ) ) {
557 foreach ( $info[$setting] as $name => $data ) {
558 if ( isset( $data[
'localBasePath'] ) ) {
559 if ( $data[
'localBasePath'] ===
'' ) {
561 $data[
'localBasePath'] = $dir;
563 $data[
'localBasePath'] =
"$dir/{$data['localBasePath']}";
566 if ( $defaultPaths ) {
567 $data += $defaultPaths;
569 $this->attributes[$setting][$name] = $data;
574 if ( isset( $info[
'QUnitTestModule'] ) ) {
575 $data = $info[
'QUnitTestModule'];
576 if ( isset( $data[
'localBasePath'] ) ) {
577 if ( $data[
'localBasePath'] ===
'' ) {
579 $data[
'localBasePath'] = $dir;
581 $data[
'localBasePath'] =
"$dir/{$data['localBasePath']}";
584 $this->attributes[
'QUnitTestModules'][
"test.{$info['name']}"] = $data;
587 if ( isset( $info[
'MessagePosterModule'] ) ) {
588 $data = $info[
'MessagePosterModule'];
589 $basePath = $data[
'localBasePath'] ??
'';
590 $baseDir = $basePath ===
'' ? $dir :
"$dir/$basePath";
591 foreach ( $data[
'scripts'] ?? [] as $scripts ) {
592 $this->attributes[
'MessagePosterModule'][
'scripts'][] =
595 foreach ( $data[
'dependencies'] ?? [] as $dependency ) {
596 $this->attributes[
'MessagePosterModule'][
'dependencies'][] = $dependency;
602 if ( isset( $info[
'ExtensionMessagesFiles'] ) ) {
603 foreach ( $info[
'ExtensionMessagesFiles'] as &
$file ) {
604 $file =
"$dir/$file";
606 $this->globals[
"wgExtensionMessagesFiles"] += $info[
'ExtensionMessagesFiles'];
618 if ( isset( $info[
'MessagesDirs'] ) ) {
619 foreach ( $info[
'MessagesDirs'] as $name => $files ) {
620 foreach ( (array)$files as
$file ) {
621 $this->globals[
"wgMessagesDirs"][$name][] =
"$dir/$file";
634 if ( isset( $info[
'ValidSkinNames'] ) ) {
635 foreach ( $info[
'ValidSkinNames'] as $skinKey => $data ) {
636 if ( isset( $data[
'args'][0][
'templateDirectory'] ) ) {
637 $templateDirectory = $data[
'args'][0][
'templateDirectory'];
638 $correctedPath = $dir .
'/' . $templateDirectory;
644 if ( is_dir( $correctedPath ) ) {
645 $data[
'args'][0][
'templateDirectory'] = $correctedPath;
647 $data[
'args'][0][
'templateDirectory'] = $templateDirectory;
649 'Template directory should be relative to skin or omitted.',
653 } elseif ( isset( $data[
'args'][0] ) ) {
655 $data[
'args'][0][
'templateDirectory'] = $dir .
'/templates';
657 $this->globals[
'wgValidSkinNames'][$skinKey] = $data;
667 if ( isset( $info[
'SkinLessImportPaths'] ) ) {
668 foreach ( $info[
'SkinLessImportPaths'] as $skin => $subpath ) {
669 $this->attributes[
'SkinLessImportPaths'][$skin] =
"$dir/$subpath";
685 foreach ( self::CREDIT_ATTRIBS as $attr ) {
686 if ( isset( $info[$attr] ) ) {
695 if ( isset( $this->credits[$name] ) ) {
696 $firstPath = $this->credits[$name][
'path'];
698 throw new Exception(
"It was attempted to load $name twice, from $firstPath and $secondPath." );
713 if ( isset( $info[
'config'] ) ) {
714 if ( isset( $info[
'config'][
'_prefix'] ) ) {
715 $prefix = $info[
'config'][
'_prefix'];
716 unset( $info[
'config'][
'_prefix'] );
720 foreach ( $info[
'config'] as $key => $val ) {
721 if ( $key[0] !==
'@' ) {
736 $prefix = $info[
'config_prefix'] ??
'wg';
737 if ( isset( $info[
'config'] ) ) {
738 foreach ( $info[
'config'] as $key => $data ) {
739 if ( !array_key_exists(
'value', $data ) ) {
740 throw new UnexpectedValueException(
"Missing value for config $key" );
743 $value = $data[
'value'];
744 if ( isset( $data[
'path'] ) && $data[
'path'] ) {
745 $callback =
static function ( $value ) use ( $dir ) {
746 return "$dir/$value";
748 if ( is_array( $value ) ) {
749 $value = array_map( $callback, $value );
751 $value = $callback( $value );
754 if ( isset( $data[
'merge_strategy'] ) ) {
755 $value[ExtensionRegistry::MERGE_STRATEGY] = $data[
'merge_strategy'];
758 $data[
'providedby'] = $info[
'name'];
759 if ( isset( $info[
'ConfigRegistry'][0] ) ) {
760 $data[
'configregistry'] = array_keys( $info[
'ConfigRegistry'] )[0];
774 if ( array_key_exists( $key, $this->globals ) ) {
775 throw new RuntimeException(
776 "The configuration setting '$key' was already set by MediaWiki core or"
777 .
" another extension, and cannot be set again by $extName." );
779 $this->globals[$key] = $value;
783 foreach ( $paths as
$path ) {
784 $this->globals[$global][] =
"$dir/$path";
798 if ( !is_array( $value ) ) {
799 throw new InvalidArgumentException(
"The value for '$name' should be an array (from $path)" );
801 if ( isset( $array[$name] ) ) {
802 $array[$name] = array_merge_recursive( $array[$name], $value );
804 $array[$name] = $value;
818 if ( !is_array( $value ) ) {
819 throw new InvalidArgumentException(
"The value for '$name' should be an array (from $path)" );
821 if ( isset( $array[$name] ) ) {
822 $array[$name] = array_merge( $array[$name], $value );
824 $array[$name] = $value;
830 if ( isset( $info[
'load_composer_autoloader'] ) && $info[
'load_composer_autoloader'] ===
true ) {
831 $paths[] =
"$dir/vendor/autoload.php";
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
extractHooks(array $info, string $path)
Extract hook information from Hooks and HookHandler attributes.
extractNamespaces(array $info)
Register namespaces with the appropriate global settings.
extractCredits( $path, array $info)
array $attributes
Any thing else in the $info that hasn't already been processed.
addConfigGlobal( $key, $value, $extName)
Helper function to set a value to a specific global, if it isn't set already.
callable[] $callbacks
Things to be called once registration of these extensions are done keyed by the name of the extension...
array $defines
Things that should be define()'d.
extractExtensionMessagesFiles( $dir, array $info)
extractConfig1(array $info)
Set configuration settings for manifest_version == 1.
array $globals
Stuff that is going to be set to $GLOBALS.
extractMessagesDirs( $dir, array $info)
Set message-related settings, which need to be expanded to use absolute paths.
extractConfig2(array $info, $dir)
Set configuration settings for manifest_version == 2.
extractResourceLoaderModules( $dir, array $info)
array $extAttributes
Extension attributes, keyed by name => settings.
extractSkins( $dir, array $info)
Extract skins and handle path correction for templateDirectory.
getExtraAutoloaderPaths( $dir, array $info)
Get the path for additional autoloaders, e.g.
extractAttributes( $path, array $info)
getRequirements(array $info, $includeDev)
Get the requirements for the provided info.
extractSkinImportPaths( $dir, array $info)
extractInfo( $path, array $info, $version)
storeToArray( $path, $name, $value, &$array)
Stores $value to $array; using array_merge() if $array already contains $name.
setStringHookHandler(string $callback, array $hookHandlersAttr, string $name, string $path)
When handler value is a string, set $wgHooks or Hooks attribute.
extractPathBasedGlobal( $global, $dir, $paths)
setArrayHookHandler(array $callback, array $hookHandlersAttr, string $name, string $path)
When handler value is an array, set $wgHooks or Hooks attribute Could be legacy hook e....
storeToArrayRecursive( $path, $name, $value, &$array)
Stores $value to $array; using array_merge_recursive() if $array already contains $name.
static array $globalSettings
Keys that should be set to $GLOBALS.
An object to represent a path to a JavaScript/CSS file, along with a remote and local base path,...
Processors read associated arrays and register whatever is required.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.