From: Ævar Arnfjörð Bjarmason Date: Fri, 9 Dec 2005 15:28:57 +0000 (+0000) Subject: * Implemented a cache for User::getMaxID() X-Git-Tag: 1.6.0~976 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=380a6661a14e96709f6b03f1d350d850ac22493e;p=lhc%2Fweb%2Fwiklou.git * Implemented a cache for User::getMaxID() --- diff --git a/includes/User.php b/includes/User.php index 057c070dc5..f3c32450b8 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1542,8 +1542,14 @@ class User { * @static */ function getMaxID() { - $dbr =& wfGetDB( DB_SLAVE ); - return $dbr->selectField( 'user', 'max(user_id)', false, 'User::getMaxID' ); + static $res; // cache + + if ( isset( $res ) ) + return $res; + else { + $dbr =& wfGetDB( DB_SLAVE ); + return $res = $dbr->selectField( 'user', 'max(user_id)', false, 'User::getMaxID' ); + } } /**