From e786a91f7a60fd712dc39053da3c14fe861af1ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 19 Sep 2011 09:04:39 +0000 Subject: [PATCH] Partial solution for bug 30972 to avoid query flood. There is still some, because the Parser doesn't use LinkBatch but does it own queries in LinkHolderArray - seriously WTF? --- includes/GenderCache.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/GenderCache.php b/includes/GenderCache.php index 60564989b2..a17ac024fc 100644 --- a/includes/GenderCache.php +++ b/includes/GenderCache.php @@ -96,12 +96,22 @@ class GenderCache { * @param $caller String: the calling method */ public function doQuery( $users, $caller = '' ) { - if ( count( $users ) === 0 ) { - return false; - } + $default = $this->getDefault(); foreach ( (array) $users as $index => $value ) { - $users[$index] = strtr( $value, '_', ' ' ); + $name = strtr( $value, '_', ' ' ); + if ( isset( $this->cache[$name] ) ) { + // Skip users whose gender setting we already know + unset( $users[$index] ); + } else { + $users[$index] = $name; + // For existing users, this value will be overwritten by the correct value + $this->cache[$name] = $default; + } + } + + if ( count( $users ) === 0 ) { + return false; } $dbr = wfGetDB( DB_SLAVE ); @@ -117,7 +127,6 @@ class GenderCache { } $res = $dbr->select( $table, $fields, $conds, $comment, $joins, $joins ); - $default = $this->getDefault(); foreach ( $res as $row ) { $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default; } -- 2.20.1