Manual:$wgUser
Appearance
From mediawiki.org
This page is a translated version of the page Manual:$wgUser and the translation is 71% complete.
Languages:
大抵の場合、
$wgUser は新しいコードでは使用すべきではありません。 If it is necessary to get a global User object, consider calling RequestContext::getMain()->getUser() instead.| グローバル オブジェクト: $wgUser | |
|---|---|
| 現在のリクエストに関連付けられた利用者のための User オブジェクト | |
| クラス: | User |
| 場所: | User.php |
詳細
User オブジェクトは、サイトでの利用者の閲覧状況/使用状況をカプセル化します。 User オブジェクトには、利用者の設定や名前などの情報を問い合わせることができます。 データベースの "user" テーブルからの取得/保存、セッションや Cookie の処理、についてその詳細を処理できます。
クライアントのクラス群は、これらのフィールドへのアクセスに getXXX() の形式の関数を使用します。
これらの関数は、利用者がログインしているかどうか、指定したオプションを Cookie が満たしているかどうか、データベースのクエリが必要かどうか、を決定するすべての作業を行います。
通常のページをレンダリングするのに必要な設定の大部分は、データベースへのアクセスを最小化するためセッション Cookie に設定されます。
$wgUser is initialized towards the end of setup.
Some hooks are called earlier than that and should avoid using it.
When in doubt use $wgUser->isSafeToLoad() to check (you can always rely on it being a User object, but it will not refer to the right user when trying to access it early).