Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -141,8 +141,7 @@ |
142 | 142 | // We're after the revision table, and the corresponding page |
143 | 143 | // row for anything we retrieve. We may also need the |
144 | 144 | // recentchanges row. |
145 | | - // Tables have to be in this order for STRAIGHT_JOIN |
146 | | - $this->addTables(array('revision', 'page')); |
| 145 | + $tables = array('page', 'revision'); // Order may change |
147 | 146 | $this->addWhere('page_id=rev_page'); |
148 | 147 | |
149 | 148 | // Handle continue parameter |
— | — | @@ -169,7 +168,8 @@ |
170 | 169 | // ... and in the specified timeframe. |
171 | 170 | // Ensure the same sort order for rev_user_text and rev_timestamp |
172 | 171 | // so our query is indexed |
173 | | - $this->addWhereRange('rev_user_text', $this->params['dir'], null, null); |
| 172 | + if($this->multiUserMode) |
| 173 | + $this->addWhereRange('rev_user_text', $this->params['dir'], null, null); |
174 | 174 | $this->addWhereRange('rev_timestamp', |
175 | 175 | $this->params['dir'], $this->params['start'], $this->params['end'] ); |
176 | 176 | $this->addWhereFld('page_namespace', $this->params['namespace']); |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled'])); |
189 | 189 | } |
190 | 190 | $this->addOption('LIMIT', $this->params['limit'] + 1); |
191 | | - $this->addOption('USE INDEX', array('revision' => 'usertext_timestamp')); |
| 191 | + $index['revision'] = 'usertext_timestamp'; |
192 | 192 | |
193 | 193 | // Mandatory fields: timestamp allows request continuation |
194 | 194 | // ns+title checks if the user has access rights for this page |
— | — | @@ -205,23 +205,33 @@ |
206 | 206 | global $wgUser; |
207 | 207 | if(!$wgUser->useRCPatrol() && !$wgUser->useNPPatrol()) |
208 | 208 | $this->dieUsage("You need the patrol right to request the patrolled flag", 'permissiondenied'); |
209 | | - $this->addTables('recentchanges'); |
210 | 209 | // Use a redundant join condition on both |
211 | 210 | // timestamp and ID so we can use the timestamp |
212 | 211 | // index |
| 212 | + $index['recentchanges'] = 'rc_user_text'; |
213 | 213 | if(isset($show['patrolled']) || isset($show['!patrolled'])) |
214 | 214 | { |
| 215 | + // Put the tables in the right order for |
| 216 | + // STRAIGHT_JOIN |
| 217 | + $tables = array('revision', 'recentchanges', 'page'); |
215 | 218 | $this->addOption('STRAIGHT_JOIN'); |
| 219 | + $this->addWhere('rc_user_text=rev_user_text'); |
216 | 220 | $this->addWhere('rc_timestamp=rev_timestamp'); |
217 | 221 | $this->addWhere('rc_this_oldid=rev_id'); |
218 | 222 | } |
219 | 223 | else |
| 224 | + { |
| 225 | + $tables[] = 'recentchanges'; |
220 | 226 | $this->addJoinConds(array('recentchanges' => array( |
221 | 227 | 'LEFT JOIN', array( |
| 228 | + 'rc_user_text=rev_user_text', |
222 | 229 | 'rc_timestamp=rev_timestamp', |
223 | 230 | 'rc_this_oldid=rev_id')))); |
| 231 | + } |
224 | 232 | } |
225 | 233 | |
| 234 | + $this->addTables($tables); |
| 235 | + $this->addOption('USE INDEX', $index); |
226 | 236 | $this->addFieldsIf('rev_page', $this->fld_ids); |
227 | 237 | $this->addFieldsIf('rev_id', $this->fld_ids || $this->fld_flags); |
228 | 238 | $this->addFieldsIf('page_latest', $this->fld_flags); |