Manual:$wgVersion/ja

From Linux Web Expert

<translate> General Settings</translate>: $wgVersion
MediaWiki のバージョン番号。
<translate> Introduced in version:</translate>1.2.0
<translate> Deprecated in version:</translate>1.35.0 (Gerrit change 481950; git #a5d5ea82)
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate>(文字列)
<translate> Default value:</translate>MediaWiki の現在のバージョン - これを変更してはいけません!

詳細

MediaWiki の現在のバージョンです (例: "1.41.1")。 このオプションを設定してはいけません。これは内部で使用されます。

MW_VERSION

<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>">
<translate> ≥</translate> 1.35
<translate> MediaWiki version:</translate>

Starting with MediaWiki 1.35, $wgVersion is deprecated, and replaced with the MW_VERSION constant. It is also available in MediaWiki 1.31.7, 1.33.3 and 1.34.1, though this should not be relied on as its presence is required for some release tools. $wgVersion will continue to function the same as before in those versions.

コード例

If you're implementing a new feature that only works in MediaWiki 1.19 or later, but you want to maintain backwards compatibility, you could use a test such as the following:

global $wgVersion;
$oldVersion = version_compare( $wgVersion, '1.18', '<=' );
if ( $oldVersion ) {
    # MediaWiki 1.18 以前の場合の処理
} else {
    # MediaWiki 1.19 以降の場合の処理
}
<td class="mw-version-versionbox" title="<translate nowrap> The latest stable version is <tvar name=1>1.41</tvar></translate>">
<translate> ≥</translate> 1.35
<translate> MediaWiki version:</translate>
$oldVersion = version_compare( MW_VERSION, '1.39', '<' );
if ( $oldVersion ) {
    #  Do stuff for MediaWiki 1.35 - 1.38
} else {
    #  Do stuff for MediaWiki 1.39+
}

However, it is typically recommended that you use feature detection to see whether the method or class you wish to use is available instead of depending upon raw version strings.

関連項目