Fix User::idFromName() ignoring cache for non-existent users.
authorAlexia E. Smith <washuu@gmail.com>
Thu, 15 Mar 2018 15:24:21 +0000 (10:24 -0500)
committerThiemo Kreuz (WMDE) <thiemo.kreuz@wikimedia.de>
Fri, 16 Mar 2018 12:10:40 +0000 (12:10 +0000)
This fixes a database time out issue where User::idFromName()
is repeatedly called from Special:Import due to the user not existing.
The response is cached as null, but isset() will return false on a null key.

Bug: T189786
Change-Id: I78705089a25dfec84d3c75bedaf623b1e5ee82c4

includes/user/User.php

index ab791b4..d6523a7 100644 (file)
@@ -885,7 +885,7 @@ class User implements IDBAccessObject, UserIdentity {
                        return null;
                }
 
-               if ( !( $flags & self::READ_LATEST ) && isset( self::$idCacheByName[$name] ) ) {
+               if ( !( $flags & self::READ_LATEST ) && array_key_exists( $name, self::$idCacheByName ) ) {
                        return self::$idCacheByName[$name];
                }