Expand documentation of User::isSafeToLoad
authorGergő Tisza <tgr.huwiki@gmail.com>
Sat, 6 Feb 2016 21:04:34 +0000 (13:04 -0800)
committerBryanDavis <bdavis@wikimedia.org>
Sat, 6 Feb 2016 22:40:43 +0000 (22:40 +0000)
Change-Id: I7f018b7f7219e7a17a3059b3ec9cbdf1c2c1e043

includes/user/User.php

index 01afd97..dccfd77 100644 (file)
@@ -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() {