Index: trunk/phase3/includes/GenderCache.php |
— | — | @@ -96,14 +96,24 @@ |
97 | 97 | * @param $caller String: the calling method |
98 | 98 | */ |
99 | 99 | public function doQuery( $users, $caller = '' ) { |
| 100 | + $default = $this->getDefault(); |
| 101 | + |
| 102 | + foreach ( (array) $users as $index => $value ) { |
| 103 | + $name = strtr( $value, '_', ' ' ); |
| 104 | + if ( isset( $this->cache[$name] ) ) { |
| 105 | + // Skip users whose gender setting we already know |
| 106 | + unset( $users[$index] ); |
| 107 | + } else { |
| 108 | + $users[$index] = $name; |
| 109 | + // For existing users, this value will be overwritten by the correct value |
| 110 | + $this->cache[$name] = $default; |
| 111 | + } |
| 112 | + } |
| 113 | + |
100 | 114 | if ( count( $users ) === 0 ) { |
101 | 115 | return false; |
102 | 116 | } |
103 | 117 | |
104 | | - foreach ( (array) $users as $index => $value ) { |
105 | | - $users[$index] = strtr( $value, '_', ' ' ); |
106 | | - } |
107 | | - |
108 | 118 | $dbr = wfGetDB( DB_SLAVE ); |
109 | 119 | $table = array( 'user', 'user_properties' ); |
110 | 120 | $fields = array( 'user_name', 'up_value' ); |
— | — | @@ -117,7 +127,6 @@ |
118 | 128 | } |
119 | 129 | $res = $dbr->select( $table, $fields, $conds, $comment, $joins, $joins ); |
120 | 130 | |
121 | | - $default = $this->getDefault(); |
122 | 131 | foreach ( $res as $row ) { |
123 | 132 | $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default; |
124 | 133 | } |