FU r106752: use "media-" instead of "images-" in container names. Long live books...
[lhc/web/wiklou.git] / includes / GenderCache.php
index 6056498..342f8db 100644 (file)
@@ -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;
                }
 
                $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;
                }