From: Gergő Tisza Date: Sat, 6 Feb 2016 21:04:34 +0000 (-0800) Subject: Expand documentation of User::isSafeToLoad X-Git-Tag: 1.31.0-rc.0~8068 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7072d4718e0caf19d965bff79f591098a1d2da43 Expand documentation of User::isSafeToLoad Change-Id: I7f018b7f7219e7a17a3059b3ec9cbdf1c2c1e043 --- diff --git a/includes/user/User.php b/includes/user/User.php index 01afd97871..dccfd77ce3 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -310,7 +310,14 @@ class User implements IDBAccessObject { } /** - * Test if it's safe to load this User object + * Test if it's safe to load this User object. You should typically check this before using + * $wgUser or RequestContext::getUser in a method that might be called before the system has + * been fully initialized. If the object is unsafe, you should use an anonymous user: + * \code + * $user = $wgUser->isSafeToLoad() ? $wgUser : new User; + * \endcode + * + * @since 1.27 * @return bool */ public function isSafeToLoad() {