* Implemented a cache for User::getMaxID()
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 9 Dec 2005 15:28:57 +0000 (15:28 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 9 Dec 2005 15:28:57 +0000 (15:28 +0000)
includes/User.php

index 057c070..f3c3245 100644 (file)
@@ -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' );
+               }
        }
 
        /**