Avoid calling Title::makeTitleSafe in User::idFromName
authorOri Livneh <ori@wikimedia.org>
Tue, 18 Nov 2014 01:52:20 +0000 (17:52 -0800)
committerOri Livneh <ori@wikimedia.org>
Tue, 18 Nov 2014 01:58:50 +0000 (17:58 -0800)
We don't want to call Title::makeTitleSafe yet, since that call path
ends up needing the user language, which ends up trying to load the
user object, which ends up back in User::idFromName.

Bug: 54193
Change-Id: I05aacd30be66fe505b5c211113ea938fa82e2492

includes/User.php

index 8fcdab2..f9f4b6a 100644 (file)
@@ -565,12 +565,10 @@ class User implements IDBAccessObject {
         * @return int|null The corresponding user's ID, or null if user is nonexistent
         */
        public static function idFromName( $name ) {
-               $nt = Title::makeTitleSafe( NS_USER, $name );
-               if ( is_null( $nt ) ) {
-                       // Illegal name
-                       return null;
-               }
-
+               // We don't want to call Title::makeTitleSafe yet, since that call path
+               // ends up needing the user language, which ends up trying to load the
+               // user object, which ends up back here (bug 54193).
+               $nt = Title::makeTitle( NS_USER, $name );
                if ( isset( self::$idCacheByName[$name] ) ) {
                        return self::$idCacheByName[$name];
                }