Merge "user: Move idFromName cache truncation to before adding the new value"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 14 Jun 2019 18:17:23 +0000 (18:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 14 Jun 2019 18:17:23 +0000 (18:17 +0000)
includes/user/User.php

index e5dfceb..2de90ed 100644 (file)
@@ -950,12 +950,12 @@ class User implements IDBAccessObject, UserIdentity {
                        $result = (int)$s->user_id;
                }
 
-               self::$idCacheByName[$name] = $result;
-
-               if ( count( self::$idCacheByName ) > 1000 ) {
+               if ( count( self::$idCacheByName ) >= 1000 ) {
                        self::$idCacheByName = [];
                }
 
+               self::$idCacheByName[$name] = $result;
+
                return $result;
        }