From 380a6661a14e96709f6b03f1d350d850ac22493e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 9 Dec 2005 15:28:57 +0000 Subject: [PATCH] * Implemented a cache for User::getMaxID() --- includes/User.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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' ); + } } /** -- 2.20.1