r97460 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97459‎ | r97460 | r97461 >
Date:09:04, 19 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
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?
Modified paths:
  • /trunk/phase3/includes/GenderCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GenderCache.php
@@ -96,14 +96,24 @@
9797 * @param $caller String: the calling method
9898 */
9999 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+
100114 if ( count( $users ) === 0 ) {
101115 return false;
102116 }
103117
104 - foreach ( (array) $users as $index => $value ) {
105 - $users[$index] = strtr( $value, '_', ' ' );
106 - }
107 -
108118 $dbr = wfGetDB( DB_SLAVE );
109119 $table = array( 'user', 'user_properties' );
110120 $fields = array( 'user_name', 'up_value' );
@@ -117,7 +127,6 @@
118128 }
119129 $res = $dbr->select( $table, $fields, $conds, $comment, $joins, $joins );
120130
121 - $default = $this->getDefault();
122131 foreach ( $res as $row ) {
123132 $this->cache[$row->user_name] = $row->up_value ? $row->up_value : $default;
124133 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r97481REL1_18 MFT r97460, r97461, r97469, r97470, r97475reedy12:58, 19 September 2011

Status & tagging log