Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -146,13 +146,16 @@ |
147 | 147 | } |
148 | 148 | |
149 | 149 | $dbr = wfGetDB( DB_SLAVE ); |
| 150 | + |
| 151 | + $ip_conds = $dbr->makeList( $this->getIpConds( $dbr, $ip, $xfor ), LIST_AND ); |
| 152 | + $cu_changes = $dbr->tableName( 'cu_changes' ); |
150 | 153 | # Limit added for browser limitations and to avoid time outs |
151 | | - $ip_conds = $this->getIpConds( $dbr, $ip, $xfor ); |
152 | | - $res = $dbr->select( 'cu_changes', '*', $ip_conds, $fname, |
153 | | - array( 'ORDER BY' => 'cuc_timestamp DESC', 'LIMIT' => 5000 ) ); |
154 | | - $ret = $dbr->resultObject( $res ); |
| 154 | + $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
| 155 | + $sql = "SELECT * FROM $cu_changes FORCE INDEX($index) WHERE $ip_conds |
| 156 | + ORDER BY cuc_timestamp DESC LIMIT 5000"; |
155 | 157 | |
156 | | - if( !$dbr->numRows( $res ) ) { |
| 158 | + $ret = $dbr->query( $sql, __METHOD__ ); |
| 159 | + if( !$dbr->numRows( $ret ) ) { |
157 | 160 | $s = wfMsgHtml("checkuser-nomatch")."\n"; |
158 | 161 | } else { |
159 | 162 | global $IP; |
— | — | @@ -177,7 +180,7 @@ |
178 | 181 | } |
179 | 182 | |
180 | 183 | $wgOut->addHTML( $s ); |
181 | | - $dbr->freeResult( $res ); |
| 184 | + $dbr->freeResult( $ret ); |
182 | 185 | } |
183 | 186 | |
184 | 187 | /** |
— | — | @@ -320,24 +323,27 @@ |
321 | 324 | { |
322 | 325 | $wgOut->addHTML( '<p>'.wfMsgHtml('checkuser-log-fail').'</p>' ); |
323 | 326 | } |
324 | | - |
| 327 | + |
325 | 328 | $sk = $wgUser->getSkin(); |
326 | 329 | |
327 | | - $users_first = $users_last = $users_edits = $users_ids = array(); |
| 330 | + $dbr = wfGetDB( DB_SLAVE ); |
328 | 331 | |
329 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 332 | + $ip_conds = $dbr->makeList( $this->getIpConds( $dbr, $ip, $xfor ), LIST_AND ); |
| 333 | + $cu_changes = $dbr->tableName( 'cu_changes' ); |
| 334 | + $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
330 | 335 | # Limit cap made to stop nasty timeouts |
331 | | - $ip_conds = $this->getIpConds( $dbr, $ip, $xfor ); |
332 | | - $res = $dbr->select( 'cu_changes', |
333 | | - array( 'cuc_user_text', 'cuc_timestamp', 'cuc_user', 'cuc_ip', 'cuc_agent', 'cuc_xff' ), |
334 | | - $ip_conds, |
335 | | - $fname, |
336 | | - array( 'ORDER BY' => 'cuc_timestamp DESC', 'LIMIT' => 10000 ) ); |
| 336 | + $sql = "SELECT cuc_user_text, cuc_timestamp, cuc_user, cuc_ip, cuc_agent, cuc_xff |
| 337 | + FROM $cu_changes FORCE INDEX($index) WHERE $ip_conds |
| 338 | + ORDER BY cuc_timestamp DESC LIMIT 10000"; |
337 | 339 | |
338 | | - if( !$dbr->numRows( $res ) ) { |
| 340 | + $ret = $dbr->query( $sql, __METHOD__ ); |
| 341 | + |
| 342 | + $users_first = $users_last = $users_edits = $users_ids = array(); |
| 343 | + |
| 344 | + if( !$dbr->numRows( $ret ) ) { |
339 | 345 | $s = wfMsgHtml( "checkuser-nomatch" )."\n"; |
340 | 346 | } else { |
341 | | - while( ($row = $dbr->fetchObject( $res ) ) != false ) { |
| 347 | + while( ($row = $dbr->fetchObject( $ret ) ) != false ) { |
342 | 348 | if( !array_key_exists( $row->cuc_user_text, $users_edits ) ) { |
343 | 349 | $users_last[$row->cuc_user_text] = $row->cuc_timestamp; |
344 | 350 | $users_edits[$row->cuc_user_text] = 0; |
— | — | @@ -417,7 +423,7 @@ |
418 | 424 | } |
419 | 425 | |
420 | 426 | $wgOut->addHTML( $s ); |
421 | | - $dbr->freeResult( $res ); |
| 427 | + $dbr->freeResult( $ret ); |
422 | 428 | } |
423 | 429 | |
424 | 430 | /** |
— | — | @@ -494,17 +500,21 @@ |
495 | 501 | $wgOut->addHTML( '<p>'.wfMsgHtml('checkuser-log-fail').'</p>' ); |
496 | 502 | } |
497 | 503 | $dbr = wfGetDB( DB_SLAVE ); |
498 | | - # Limit cap made to stop nasty time outs |
499 | | - $res = $dbr->select( 'cu_changes', array( 'cuc_ip', 'cuc_timestamp' ), |
500 | | - array( 'cuc_user' => $user_id ), |
501 | | - $fname, |
502 | | - array( 'ORDER BY' => 'cuc_timestamp DESC', 'LIMIT' => 10,000 ) ); |
503 | | - if( !$dbr->numRows( $res ) ) { |
| 504 | + |
| 505 | + $cu_changes = $dbr->tableName( 'cu_changes' ); |
| 506 | + # Limit cap made to stop nasty timeouts |
| 507 | + $sql = "SELECT cuc_ip, cuc_timestamp |
| 508 | + FROM $cu_changes FORCE INDEX(cuc_user_time) WHERE cuc_user = $user_id |
| 509 | + ORDER BY cuc_timestamp DESC LIMIT 10000"; |
| 510 | + |
| 511 | + $ret = $dbr->query( $sql, __METHOD__ ); |
| 512 | + |
| 513 | + if( !$dbr->numRows( $ret ) ) { |
504 | 514 | $s = wfMsgHtml("checkuser-nomatch")."\n"; |
505 | 515 | } else { |
506 | 516 | $blockip = SpecialPage::getTitleFor( 'blockip' ); |
507 | 517 | $ips_edits=array(); |
508 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 518 | + while( $row = $dbr->fetchObject( $ret ) ) { |
509 | 519 | if( !array_key_exists( $row->cuc_ip, $ips_edits ) ) { |
510 | 520 | $ips_edits[$row->cuc_ip]=0; |
511 | 521 | $ips_last[$row->cuc_ip]=$row->cuc_timestamp; |
— | — | @@ -546,6 +556,7 @@ |
547 | 557 | $s .= '</ul>'; |
548 | 558 | } |
549 | 559 | $wgOut->addHTML( $s ); |
| 560 | + $dbr->freeResult( $ret ); |
550 | 561 | } |
551 | 562 | |
552 | 563 | function showLog( $user ) { |