From: Alexia E. Smith Date: Fri, 14 Jun 2019 17:40:54 +0000 (-0500) Subject: user: Move idFromName cache truncation to before adding the new value X-Git-Tag: 1.34.0-rc.0~1399^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=aa9bbc47c3b043479aba45ab8e76b663826b780f;p=lhc%2Fweb%2Fwiklou.git user: Move idFromName cache truncation to before adding the new value This prevents a double query for the same User::idFromName() call twice in a row. Bug: T225843 Change-Id: I5beb0a3ad5e715b68dd8a450408fb089184fa6ce --- diff --git a/includes/user/User.php b/includes/user/User.php index e5dfcebe5e..2de90edb4b 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -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; }