Manual:$wgExtensionFunctions

From mediawiki.org
This page is a translated version of the page Manual:$wgExtensionFunctions and the translation is 58% complete.
Outdated translations are marked like this.
拡張機能: $wgExtensionFunctions
MediaWikiが完全に初期化された時点で呼び出される、コールバック関数の一覧
導入されたバージョン:1.3.0 (r3583)
除去されたバージョン:使用中
許容される値:未指定
既定値:[]

詳細

一般論として、この機能の使用はハック (巧妙な改造) であり、MediaWikiコアか拡張機能か、どこかで何かがうまく処理できていないことを示唆しています。そのような事態は避けるべきです。

この変数は、MediaWikiの初期化がほぼ完了した時点で呼び出される関数を格納する配列です。 Extensions can register callbacks to be executed this way using the ExtensionFunctions of extension.json. At the time these callbacks are called, MediaWikiServices and the main RequestContext are fully initialized.

あるいはまた、この時点ですでに特定の設定変数が処理済みの可能性があり、それらを変更するリスクにご留意ください。 Extensions that need to dynamically set configuration should use a registration callback instead.

ExtensionFunction callbacks should be used only for initialization code that need to interact with service objects as a final step.

たとえば、ご利用の拡張機能が初期化においてデータベースへのアクセスが必要な場合の処理法:

function initMyExtension() {
      $dbr = MediaWikiServices::getInstance()
            ->getConnectionProvider->getReplicaDatabase();
      $myExtension = new MyExtension();
      $myExtension->loadSettingsFromDatabase( $dbr );
}

関連項目