Manual:extension.json/スキーマ

This page is a translated version of the page Manual:Extension.json/Schema and the translation is 2% complete.

このページでは extension.json で使われるスキーマに関して説明しています。 特に指定がない限りすべての項目の指定は任意です。 現時点では不完全です。

For the first iteration of this schema see docs/extension.schema.v1.json (MW 1.25+), for the second see docs/extension.schema.v2.json (MW 1.29+).

manifest_version

MediaWiki バージョン:
1.25
Gerrit change 212239

このフィードは必須です。

This specifies the version of the extension.json file format that is being used. In the future if breaking changes are made to the file format, this number will be incremented to continue supporting extensions using the older format.

Currently the following values are supported:

  • 1: 1.25+
  • 2: 1.29+

v2 provides stronger developer validation features, and is recommended if your extension already requires MediaWiki 1.29+. It is not recommended to break MediaWiki compatibility with older versions just to upgrade to a newer manifest_version.

Currently new features are added to both v1 and v2, but it has been proposed to freeze and soft deprecate v1 in the MediaWiki 1.38 release (discuss on Phabricator).

例:

{
	"manifest_version": 2
}
This field is typically placed at the bottom of extension.json files.

name

MediaWiki バージョン:
1.25
Gerrit change 166705

This field is required.

This is the extension's canonical name. It should not be changed once set, as it is used as an API for other extensions to detect what is installed. The name field does not have to match an extension's directory name nor the name of its page in the Extension namespace on MediaWiki.org.

{
	"name": "FooBar"
}

namemsg

MediaWiki バージョン:
1.25
Gerrit change 166705

A localized version of the extension's name. Typically the message key is named in the format <name>-extensionname or <name>-skinname.

{
	"namemsg": "foobar-extensionname"
}

type

MediaWiki バージョン:
1.25
Gerrit change 166705

The type of extension it is, for sorting on Special:Version. The following types are supported:

Custom types can be added by using the ExtensionTypes hook. Known ones include:

If not set, the extension will default to the "other" section, and if set to an invalid value the extension will not appear on Special:Version.

{
	"type": "specialpage"
}

author

MediaWiki バージョン:
1.25
Gerrit change 166705

The authors of the extension, may contain wikitext. This can either be a single string, or an array of strings. Additionally, the special string ... may be used to add a generic "その他" suffix using the version-poweredby-others message.

version

MediaWiki バージョン:
1.25
Gerrit change 166705

The current version of the extension. Should be in a format supported by Composer.

url

MediaWiki バージョン:
1.25
Gerrit change 166705

URL to the extension's "homepage" or documentation. Typically points to https://www.mediawiki.org/wiki/Extension:<extensionname>.

description

MediaWiki バージョン:
1.25
Gerrit change 166705

Description of the extension, may contain wikitext.   注: It is recommended to use descriptionmsg instead.

descriptionmsg

MediaWiki バージョン:
1.25
Gerrit change 166705

Localization message key for the extension's description, typically in the format <extensionname>-desc. This will override description.

license-name

MediaWiki バージョン:
1.25
Gerrit change 166705

The SPDX license identifier for the license the source code is licensed as. If you create a file named COPYING or LICENSE (with an optional .txt extension) in the extension root directory with the contents of the license, it will also be linked and visible from Special:Version.

requires

MediaWiki バージョン:
1.26
Gerrit change 210856
MediaWiki バージョン:
1.29
Gerrit change 250060

The requires section allows you to document dependencies on versions of MediaWiki core (1.26+) and other extensions (1.29+).

{
	"requires": {
		"MediaWiki": ">= 1.27.0",
		"extensions": {
			"FooBar": "*",
			"Baz": ">= 1.2.3"
		}
	}
}

You can use any version specifier that composer supports. For MediaWiki, it is best practice to specify a >= for the minimum supported version, unless you know a future version is explicitly broken. For extensions, if they don't have a version specifier set, or don't use a versioning system, use a plain * to indicate any version is acceptable.

If your extension uses Wikimedia Continuous integration, you also need to add extension dependencies to zuul/parameter_functions.py in the integration/config project.

platform

MediaWiki バージョン:
1.32
Gerrit change 458940
MediaWiki バージョン:
1.32
Gerrit change 462596

You can also express a dependency on platform settings, currently limited to PHP version and PHP extensions. Note that most extensions are expected to follow the PHP version requirements for the versions of MediaWiki core they support, and specifying a more restrictive PHP version contraint should only be done in exceptional cases. Checking for PHP extension versions isn't supported right now.

{
	"requires": {
		"MediaWiki": ">= 1.32.0",
		"platform": {
			"php": ">= 7.1",
			"ext-curl": "*"
		}
	}
}

In this example, the extension requires 1.32 (which has a minimum requirement of PHP 7.0), and additionally expresses that it needs a higher dependency of at least PHP 7.1 since it requires usage of some newer PHP feature. Furthermore, it required the curl PHP extension to be installed.

suggests

MediaWiki バージョン:
1.39
Gerrit change 591897

Allows listing suggested but not required dependencies. The format is identical to requires.

ResourceFileModulePaths

MediaWiki バージョン:
1.25
Gerrit change 188996

Specifies the default paths to use for all ResourceLoader file modules.

The allowed properties are:

  • localBasePath
  • remoteExtPath (must not point to other extension folders)
  • remoteSkinPath

These correspond to the same options in each module definition in ResourceModules. If a value is not specified in the module definition, the default value specified here will be used.

{
	"ResourceFileModulePaths": {
		"localBasePath": "resources",
		"remoteExtPath": "FooBar/resources"
	}
}

ResourceModules

MediaWiki バージョン:
1.25
Gerrit change 166705

ResourceLoader modules to register.

このオプションは、グローバル変数 $wgResourceModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ResourceModuleSkinStyles

MediaWiki バージョン:
1.25
Gerrit change 201661

ResourceLoader modules for custom skin styles.

このオプションは、グローバル変数 $wgResourceModuleSkinStyles に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ResourceLoaderSources

MediaWiki バージョン:
1.25
Gerrit change 166705

ResourceLoader sources to register.

このオプションは、グローバル変数 $wgResourceLoaderSources に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ResourceLoaderLESSVars

MediaWiki バージョン:
1.25 – 1.30
Gerrit change 166705

An associative array binding variable names to LESS code snippets representing their values.

このオプションは、グローバル変数 $wgResourceLoaderLESSVars に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


SkinLessImportPaths

MediaWiki バージョン:
1.36
Gerrit change 434211

Path to the skin-specific LESS import directory, keyed by skin name. Can be used to define skin-specific LESS variables.

QUnitTestModule

MediaWiki バージョン:
1.33
Gerrit change 485247

A ResourceLoader file module, to loaded when running JavaScript unit tests. This follows the same syntax as ResourceModules.

Internally, when $wgEnableJavaScriptTest is true, this module is automatically registered under the name "test.ExtensionName".

MessagePosterModule

MediaWiki バージョン:
1.35
Gerrit change 542655

Allows extensions to add additional files or dependencies to the mediawiki.messagePoster module bundle. This follows the same syntax as ResourceModules.

ConfigRegistry

MediaWiki バージョン:
1.25
Gerrit change 166705

Registry of factory functions to create Config objects.

このオプションは、グローバル変数 $wgConfigRegistry に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


SessionProviders

MediaWiki バージョン:
1.27
Gerrit change 288324

Specifies what providers to use for SessionManager.

このオプションは、グローバル変数 $wgSessionProviders に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


AuthManagerAutoConfig

MediaWiki バージョン:
1.27
Gerrit change 195297

AuthManager auto-configuration.

このオプションは、グローバル変数 $wgAuthManagerAutoConfig に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


The following properties are available:

  • preauthPre-authentication providers.
  • primaryauthPrimary authentication providers.
  • secondaryauthSecondary authentication providers.

CentralIdLookupProviders

MediaWiki バージョン:
1.27
Gerrit change 261909

Central ID lookup providers.

このオプションは、グローバル変数 $wgCentralIdLookupProviders に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ChangeCredentialsBlacklist

MediaWiki バージョン:
1.28
Gerrit change 294859

AuthenticationRequest classes which can only be used internally for credential change.

このオプションは、グローバル変数 $wgChangeCredentialsBlacklist に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RemoveCredentialsBlacklist

MediaWiki バージョン:
1.28
Gerrit change 294859

AuthenticationRequest classes which can only be used internally for credential removal.

このオプションは、グローバル変数 $wgRemoveCredentialsBlacklist に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


namespaces

MediaWiki バージョン:
1.25.3
Gerrit change 237973

Method to add extra namespaces .

The following properties are available:

  • idAn integer. The numeric identifier of the namespace, as used in the database. Since MW 1.30, the namespace ID can be overwritten locally, by defining the respective constant in LocalSettings.php before loading the extension. Extension code must therefore always use the constant for the namespace ID, and never use the ID as a literal in PHP code. Consider listing your id number used at Extension default namespaces to avoid conflicts with other extensions.
  • constantA string. The name of the constant that the extension code uses to refer to the namespace ID.
  • nameA string. The name of the namespace, as used in titles.
  • genderGender object. Properties are either "male" or "female". See gender support.
  • subpagesBoolean. Default is false. See Manual:$wgNamespacesWithSubpages .
  • contentBoolean. Default is false. See Manual:$wgContentNamespaces .
  • defaultcontentmodelA string. See ContentHandler .
  • protectionUserright(s) required to edit in this namespace. An array or string.
  • capitallinkoverrideSet $wgCapitalLinks on a per-namespace basis. Boolean.
  • conditionalWhether the namespace is conditional upon configuration and should not be registered (requires separate registration via a hook such as CanonicalNamespaces ). Boolean. Default is false.
  • movableWhether it is possible to move pages in this namespace. Boolean. Default is true. MW 1.35.2+

TrackingCategories

MediaWiki バージョン:
1.25
Gerrit change 166705

Tracking category message keys.

このオプションは、グローバル変数 $wgTrackingCategories に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


DefaultUserOptions

MediaWiki バージョン:
1.25
Gerrit change 166705


このオプションは、グローバル変数 $wgDefaultUserOptions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。

	"DefaultUserOptions": {
		"math": "png"
	},

HiddenPrefs

MediaWiki バージョン:
1.25
Gerrit change 166705

Preferences users cannot set.

このオプションは、グローバル変数 $wgHiddenPrefs に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


GroupPermissions

MediaWiki バージョン:
1.25
Gerrit change 166705

Default permissions to give to user groups.

このオプションは、グローバル変数 $wgGroupPermissions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


PrivilegedGroups

MediaWiki バージョン:
1.41
Gerrit change 954742

User groups that should be considered privileged.

このオプションは、グローバル変数 $wgPrivilegedGroups に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RevokePermissions

MediaWiki バージョン:
1.25
Gerrit change 166705

Default permissions to revoke from user groups.

このオプションは、グローバル変数 $wgRevokePermissions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


GrantPermissions

Map of permissions granted to authorized consumers to their bundles, called 'grants.'

このオプションは、グローバル変数 $wgGrantPermissions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


GrantPermissionGroups

Map of grants to their UI grouping.

このオプションは、グローバル変数 $wgGrantPermissionGroups に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ImplicitGroups

Implicit groups.

このオプションは、グローバル変数 $wgImplicitGroups に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


GroupsAddToSelf

Groups a user can add to themselves.

このオプションは、グローバル変数 $wgGroupsAddToSelf に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


GroupsRemoveFromSelf

Groups a user can remove from themselves.

このオプションは、グローバル変数 $wgGroupsRemoveFromSelf に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


AddGroups

Groups a user can add to users.

このオプションは、グローバル変数 $wgAddGroups に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RemoveGroups

Groups a user can remove from users.

このオプションは、グローバル変数 $wgRemoveGroups に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


AvailableRights

User rights added by the extension.

このオプションは、グローバル変数 $wgAvailableRights に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ContentHandlers

Mapping of Model ID to class name.

このオプションは、グローバル変数 $wgContentHandlers に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RateLimits

Simple rate limiter options to brake edit floods.

このオプションは、グローバル変数 $wgRateLimits に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RecentChangesFlags

Flags (letter symbols) shown in recent changes and watchlist to indicate certain types of edits.

このオプションは、グローバル変数 $wgRecentChangesFlags に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


MediaHandlers

Plugins for media file type handling. Each entry in the array map maps a MIME type to a PHP class name.

このオプションは、グローバル変数 $wgMediaHandlers に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ExtensionFunctions

Function to call after setup has finished.

このオプションは、グローバル変数 $wgExtensionFunctions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


Note that extension functions cannot be used to programmatically update configuration variables or register hooks. For that purpose, a registration callback should be used instead.

ExtensionMessagesFiles

File paths containing PHP internationalization files.

このオプションは、グローバル変数 $wgExtensionMessagesFiles に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


MessagesDirs

Directory paths containing JSON internationalization data.

このオプションは、グローバル変数 $wgMessagesDirs に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


If you use the default directory layout with localized messages in the i18n/ directory, you can specify:

"MessagesDirs": {
	"ExtensionName": [
		"i18n"
	]
},

ExtensionEntryPointListFiles

Array of files with list(s) of extension entry points to be used in maintenance/mergeMessageFileList.php

このオプションは、グローバル変数 $wgExtensionEntryPointListFiles に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


SpecialPages

SpecialPages implemented in this extension (mapping of page name to class name).

このオプションは、グローバル変数 $wgSpecialPages に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


AutoloadClasses

Array mapping class names to filenames, for autoloading.

このオプションは、グローバル変数 $wgAutoloadClasses に直接対応しています。 設定方法は、そちらの説明文書を参照してください。

Example:

{
    ...
    "AutoloadClasses": {
        "MyClassName": "includes/FileContainingMyClassName.php",
        "SomeNamespace\\SpecialHelloWorld": "specials/SpecialHelloWorld.php"
    },
    ...
}

AutoloadNamespaces

MediaWiki バージョン:
1.31
Gerrit change 373626

Array containing mapping of namespaces to directories in a PSR-4 compatible manner. Here's an example:

{
	"AutoloadNamespaces": {
		"MediaWiki\\Extension\\BetaFeatures\\": "includes/"
	}
}

In this case all of the PHP classes are under the MediaWiki\Extension\BetaFeatures\ namespace, and the naming of the classes directly maps to the files located in the includes/ directory (relative to the extension.json file). Note that the namespace portion must end with \\.

Extensions using this feature should require at least MediaWiki 1.31 in extension.json file:

{
	"requires": {
		"MediaWiki": ">= 1.31.0"
	},
}

For example, see Gerrit change 468385.

TestAutoloadClasses and TestAutoloadNamespaces

MediaWiki バージョン:
1.35
Gerrit change 556181

Both are the same as AutoloadClasses and AutoloadNamespaces, except that they are only used when running tests.

For example, see Gerrit change 556240.

Hooks

Hooks this extension uses (mapping of hook name to callback).

このオプションは、グローバル変数 $wgHooks に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


{
	"Hooks": {
		"ParserFirstCallInit": "MassMessageHooks::onParserFirstCallInit"
	}
}

It's possible to register multiple callbacks for the same hook event:

{
	"Hooks": {
		"ParserFirstCallInit": [
			"MassMessageHooks::onParserFirstCallInitOne",
			"MassMessageHooks::onParserFirstCallInitTwo"
		]
	}
}

HookHandlers

MediaWiki バージョン:
1.35
Gerrit change 596914

ObjectFactory specifications for new-style hook handlers.

{
    "Hooks": {
        "BeforePageDisplay": "main"
    },
    "HookHandlers": {
        "main": {
            "class": "MediaWiki\\Extension\\MyExtension\\HookHandler",
            "services": [ "UserNameUtils" ]
        }
    }
}

There is a difference with the previous approach in that:

  • Your HookHandler must import the hooks with the use keyword.
  • The HookHandler class must also implement them.
  • The functions using those hooks in your HookHandler class cannot be called statically, i.e. are dynamic rather than static.

DeprecatedHooks

MediaWiki バージョン:
1.35
Gerrit change 596914

Deprecated hooks (see Stable interface policy). Maps hook name to an array with deprecatedVersion (MediaWiki version) and component (optional, usually omitted).

JobClasses

Job types this extension implements (mapping of job types to class name).

このオプションは、グローバル変数 $wgJobClasses に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogTypes

List of new log types this extension uses.

このオプションは、グローバル変数 $wgLogTypes に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogRestrictions

Restricts log access to those who have a certain right.

このオプションは、グローバル変数 $wgLogRestrictions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


FilterLogTypes

An object.

このオプションは、グローバル変数 $wgFilterLogTypes に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ActionFilteredLogs

List of log types which can be filtered by log actions.

このオプションは、グローバル変数 $wgActionFilteredLogs に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogNames

Lists the message key string for each log type.

このオプションは、グローバル変数 $wgLogNames に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogHeaders

Lists the message key string for descriptive text to be shown at the top of each log type.

このオプションは、グローバル変数 $wgLogHeaders に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogActions

Lists the message key string for formatting individual events of each type and action when listed in the logs.

このオプションは、グローバル変数 $wgLogActions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LogActionsHandlers

Same as $wgLogActions , but values are functions callbacks.

このオプションは、グローバル変数 $wgLogActionsHandlers に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


Actions

Array of allowed values for the "action" parameter for normal pages.

このオプションは、グローバル変数 $wgActions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


APIModules

API module extensions.

このオプションは、グローバル変数 $wgAPIModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


APIFormatModules

API format module extensions.

このオプションは、グローバル変数 $wgAPIFormatModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


APIMetaModules

API Query meta module extensions.

このオプションは、グローバル変数 $wgAPIMetaModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


APIPropModules

API Query prop module extensions.

このオプションは、グローバル変数 $wgAPIPropModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


APIListModules

API Query list module extensions.

このオプションは、グローバル変数 $wgAPIListModules に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RestRoutes

MediaWiki バージョン:
1.35
Gerrit change 508972

List of route specifications to be added to the REST API. See API:REST API/Extensions.

ValidSkinNames

List of valid skin names. Skins can optionally use this variable to tell MediaWiki that they are available.

このオプションは、グローバル変数 $wgValidSkinNames に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


FeedClasses

Available feed objects.

このオプションは、グローバル変数 $wgFeedClasses に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


SkinOOUIThemes

Map of skin names to OOUI themes to use.

{
	"SkinOOUIThemes": {
		"yourskinname": "Apex"
	}
}

OOUIThemePaths

Map of custom OOUI theme names to paths to load them from.

{
	"OOUIThemePaths": {
		"YourTheme": {
			"scripts": "resources/ooui/oojs-ui-yourtheme.js",
			"styles": "resources/ooui/oojs-ui-{module}-yourtheme.css",
			"images": "resources/ooui/{module}.json"
		}
	},
}
scripts
Path to script file.
styles
Path to style files. {module} will be replaced with the module's name.
images
Path to image definition files. {module} will be replaced with the module's name. If the files don't exist, default theme's images will be used instead.

PasswordPolicy

Password policies.

このオプションは、グローバル変数 $wgPasswordPolicy に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


FileExtensions

Preferred file extensions for uploading.

このオプションは、グローバル変数 $wgFileExtensions に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


RawHtmlMessages

List of messages which might contain raw HTML.

このオプションは、グローバル変数 $wgRawHtmlMessages に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


LateJSConfigVarNames

Names of JS config vars (as used in MakeGlobalVariablesScript hook or in ParserOutput::setJsConfigVar) that may be set from the end of the HTML body instead of the HTML head, to improve page load time. In JavaScript, these variables should be accessed via mw.hook( 'wikipage.content' ).

DatabaseVirtualDomains

Names of virtual domains that are used to get a db connection. See $wgVirtualDomainsMapping .

ReauthenticateTime

Time frame for re-authentication.

このオプションは、グローバル変数 $wgReauthenticateTime に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ForeignResourcesDir

MediaWiki バージョン:
1.41
Gerrit change 911307

Directory containing the extension's foreign resources (and the foreign-resources.yaml file defining them). Should be given relative to the extension root.

callback

Sometimes extensions need to do non-standard things during registration, or are just very complex. You can specify a callback key in your extension.json if you need to execute some PHP code. The value should be set to a valid PHP callable, for example: FooBarHooks::onRegistration. ExtensionRegistry will execute this callback after it processes the extension.json file and sets all the other globals and configuration settings. This happens after LocalSettings, so all user-specified configuration is available, but some defaults set by MediaWiki might not have been initialized yet.

{
	"callback": "FooBarHooks::onRegistration"
}

The callback is provided with two parameters, an array containing information about the extension (a subset of extension.json) and an instance of SettingsBuilder MW 1.40+.

The callback isn't a normal hook function, it runs in early initialization. See Manual:Extension registration/Limitations for what sort of things may require custom registration.

Registration callbacks are the preferred way for extensions to dynamically set configuration. This should be done through the SettingsBuilder object passed to callback, using the getConfig() and overrideConfigValue() methods.

Registration callbacks do not have access to service objects via MediaWikiServices, and cannot make use of the main RequestContext. Neither has been initialized at the time the callback is executed. Extensions that need to access the request context or interact with a service object during initialization should register an ExtensionFunction instead.

config

MediaWiki バージョン:
1.25

The config section is where you can define configuration settings that sysadmins can change to configure the extension. This section should only be used for things that are configured in LocalSettings.php - if it is supposed to be modified by other extensions, you should use attributes, or if it is just class metadata, use a private static variable or something like that. The format of config changed in manifest_version 2.

Manifest version 1

A simple example:

{
    "config": {
        "FooBarUseExtraFeature": false
    }
}

This is equivalent to writing $wgFooBarUseExtraFeature = false; in PHP. Note that the typical "wg" prefix is not included, as that will be added by default. If your settings start with a different prefix like $eg, you can use the magic _prefix key:

{
	"config": {
		"_prefix": "eg",
		"FooBarUseExtraFeature": false
	}
}

This is now equivalent to writing $egFooBarUseExtraFeature = false; in PHP.

A more complex example:

{
	"config": {
		"FooBarEnabledNamespaces": {
			"0": true,
			"2": true,
			"4": true,
			"_merge_strategy": "array_plus"
		},
		"FooBarCoolStuff": {
			"sysop": {
				"foo": true,
				"bar": false
			},
			"_merge_strategy": "array_plus_2d"
		}
	}
}

The first setting, $wgFooBarEnabledNamespaces, has keys that are numbers, so PHP will turn them into integers, even though they are strings in JSON. Because of how PHP treats integer keys when merging arrays, we need to use a different type of merge here, so we set a different "merge strategy" using the magic key. In the second example, we have a nested array, which requires a different type of merging, since we want to allow people to continue writing $wgFooBarCoolStuff['user']['foo'] = true; in their LocalSettings.php.

Changes in manifest version 2

MediaWiki バージョン:
1.29

With MediaWiki 1.29, a new manifest_version (2) was introduced. In this version, the config section is improved in several ways. To support these changes, the signature of a set of configuration option and configuration value changed a bit. The key of the config object is still the configuration name; however, the value of that key is an object, which describes this configuration option, where one of the values is the value. You can find information about what the specific keys and values for a configuration option are on the extension registration documentation page. An easy example of the new schema, which simply is one configuration option and its value, would look like:

{
	"config": {
		"FooBarUseExtraFeature": {
			"value": false
		}
	},
	"manifest_version": 2
}

A more complex one would look like:

{
	"config_prefix": "eg",
	"config": {
		"MyExtSetting": {
			"value": true,
			"path": false,
			"description": "The description for the configuration",
			"descriptionmsg": "myextension-config-myextsetting",
			"public": true
		},
		"FooBarCoolStuff": {
			"value": {
				"sysop": {
					"foo": true,
					"bar": false
				}
			},
		    "merge_strategy": "array_plus_2d"
		}
	},
	"manifest_version": 2
}
The version 2 of the schema is incompatible with version 1. Thus you will have to convert your existing "extension.json" file to the new format using the updateExtensionJsonSchema.php script.

path

As demonstrated in the example above, a configuration option can have the path key defined. When present and set to true, the value of the setting will be interpreted as a path local to the extension. For example, an extension might define its configuration as

{
	"config": {
		"Setting": {
			"value": "some_file.txt",
			"path": true
		}
	},
	"manifest_version": 2
}

The value for the configuration option "Setting" will be resolved to $wgExtensionDirectory/FooBar/some_file.txt.

merge strategy

The merge strategy defines how to merge the default value of the configuration setting with the global value (the value of the $wgXXX global variable). This only makes sense for array-valued configuration settings. The following merge strategies are available:

  • array_mergeUses the array_merge PHP command: array elements with numeric keys will be interpreted as non-associative list items and concatenated to the array (with the keys renumbered if needed), array elements with non-numeric keys will be interpreted as hashmap items and overwrite items with the same key.
  • array_plusUses the + PHP operator, so fields of the default value will only be used when the corresponding field is not set in the global value. This is useful for associative arrays with integer keys (such as namespace IDs).
  • array_plus_2dUses wfArrayPlus2d to handles nested arrays to a depth of 2 properly (e.g. $wgGroupPermissions ).
  • array_merge_recursiveHandles arrays even deeper than 2 with array_merge_recursive. Given the unintuitive behavior of this method (example), this strategy is not recommended. A configuration setting that is more than 2 levels deep suggests too many things are being configured in one setting, and splitting it into multiple settings might be a good idea.
  • array_replace_recursiveUses array_replace_recursive, basically the recursive version of array_plus. Unlike array_merge_recursive, this will handle non-array fields the way one would expect.
  • provide_default (since MW 1.35.3) — no merging; the default will only be used when no global value is set.

When not explicitly set, the merge strategy defaults to array_merge. When at least one of the global value and the default is not an array, the merge strategy is ignored and the global value will simply override the default.

config_prefix

MediaWiki バージョン:
1.28

Prefix to put in front of configuration settings when exporting them to $GLOBALS.

The default is "wg", so a configuration setting "Example" corresponds to a PHP global $wgExample. Note that choosing a different config prefix can make it more difficult to find the extension setting corresponding to a given global.

ParsoidModules

MediaWiki バージョン:
1.35
Gerrit change 597639

A list of Parsoid extension module specifiers. A Parsoid extension module is a class implementing Wikimedia\Parsoid\Ext\ExtensionModule; a specifier is a class name or ObjectFactory specification or a Parsoid-specific module specification.

やるべきこと(TODO): document


ParserTestFiles

Parser test suite files to be run by parserTests.php when no specific filename is passed to it.

このオプションは、グローバル変数 $wgParserTestFiles に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


ServiceWiringFiles

Array of filenames of service wiring files to be loaded by the default instance of MediaWikiServices.

このオプションは、グローバル変数 $wgServiceWiringFiles に直接対応しています。 設定方法は、そちらの説明文書を参照してください。


attributes

Registration information for other extensions. This allows one extension to register things with other extensions. Attribute values must be JSON arrays or objects, and they will be merged together when retrieved in PHP.

In manifest_version 1 these were top level keys that could be arbitrarily named:

"EventLoggingSchemas": {
    "MySchema": 123
}

In manifest_version 2, these are now under the top level attributes key, and then nested under the extension name that the attribute belongs towards.

The full attribute name is the concatenation of the extension name and attribute name (EventLoggingSchemas in the example below). Each key set directly under attributes must match the extension name (arbitrary top-level attribute keys are not supported). If an extension (EventLogging in this example) is not installed, the attributes won't be loaded into the registry.

"attributes": {
    "EventLogging": {
        "Schemas": {
            "MySchema": 123
        }
    }
}

To access the value of an attribute in PHP, you can use the ExtensionRegistry:

$schemas = ExtensionRegistry::getInstance()->getAttribute( 'EventLoggingSchemas' );

load_composer_autoloader

Load the composer autoloader for this extension, if one is present. This should be used if the extension has dependencies on libraries that are specified in composer.json. It is basically equivalent to the following code:

if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
	require_once __DIR__ . '/vendor/autoload.php';
}