Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -275,21 +275,30 @@ |
276 | 276 | $sql = "SELECT cuc_ip,cuc_ip_hex, COUNT(*) AS count, |
277 | 277 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
278 | 278 | FROM $cu_changes $use_index WHERE cuc_user = $user_id AND $time_conds |
279 | | - GROUP BY cuc_ip,cuc_ip_hex ORDER BY last DESC LIMIT 5000"; |
| 279 | + GROUP BY cuc_ip,cuc_ip_hex ORDER BY last DESC LIMIT 5001"; |
280 | 280 | |
281 | 281 | $ret = $dbr->query( $sql, __METHOD__ ); |
282 | | - |
283 | 282 | if( !$dbr->numRows( $ret ) ) { |
284 | 283 | $s = wfMsgHtml("checkuser-nomatch")."\n"; |
285 | 284 | } else { |
286 | 285 | $blockip = SpecialPage::getTitleFor( 'blockip' ); |
287 | 286 | $ips_edits = array(); |
| 287 | + $counter = 0; |
288 | 288 | while( $row = $dbr->fetchObject($ret) ) { |
| 289 | + if( $counter >= 5000 ) { |
| 290 | + $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 291 | + break; |
| 292 | + } |
289 | 293 | $ips_edits[$row->cuc_ip] = $row->count; |
290 | 294 | $ips_first[$row->cuc_ip] = $row->first; |
291 | 295 | $ips_last[$row->cuc_ip] = $row->last; |
292 | 296 | $ips_hex[$row->cuc_ip] = $row->cuc_ip_hex; |
| 297 | + ++$counter; |
293 | 298 | } |
| 299 | + // Count pinging might take some time...make sure it is there |
| 300 | + wfSuppressWarnings(); |
| 301 | + set_time_limit(60); |
| 302 | + wfRestoreWarnings(); |
294 | 303 | |
295 | 304 | $logs = SpecialPage::getTitleFor( 'Log' ); |
296 | 305 | $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
— | — | @@ -388,7 +397,7 @@ |
389 | 398 | # Check how many rows will need sorting ahead of time to see if this is too big. |
390 | 399 | # Also, if we only show 5000, too many will be ignored as well. |
391 | 400 | $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
392 | | - if( strpos($ip,'/') !==false ) { |
| 401 | + if( strpos($ip,'/') !== false ) { |
393 | 402 | # Quick index check only OK if no time constraint |
394 | 403 | if( $period ) { |
395 | 404 | $rangecount = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
— | — | @@ -406,6 +415,7 @@ |
407 | 416 | set_time_limit(60); |
408 | 417 | wfRestoreWarnings(); |
409 | 418 | } |
| 419 | + $counter = 0; |
410 | 420 | # See what is best to do after testing the waters... |
411 | 421 | if( isset($rangecount) && $rangecount > 5000 ) { |
412 | 422 | $use_index = $dbr->useIndexClause( $index ); |
— | — | @@ -413,12 +423,16 @@ |
414 | 424 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
415 | 425 | FROM $cu_changes $use_index |
416 | 426 | WHERE $ip_conds AND $time_conds |
417 | | - GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5000"; |
| 427 | + GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
418 | 428 | $ret = $dbr->query( $sql, __METHOD__ ); |
419 | 429 | # List out each IP that has edits |
420 | | - $s = '<h5>' . wfMsg('checkuser-too-many') . '</h5>'; |
| 430 | + $s = wfMsgExt('checkuser-too-many',array('parse')); |
421 | 431 | $s .= '<ol>'; |
422 | 432 | while( $row = $ret->fetchObject() ) { |
| 433 | + if( $counter >= 5000 ) { |
| 434 | + $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 435 | + break; |
| 436 | + } |
423 | 437 | # Convert the IP hexes into normal form |
424 | 438 | if( strpos($row->cuc_ip_hex,'v6-') !==false ) { |
425 | 439 | $ip = substr( $row->cuc_ip_hex, 3 ); |
— | — | @@ -436,6 +450,7 @@ |
437 | 451 | ' -- ' . $wgLang->timeanddate( $row->last, true ) . ') '; |
438 | 452 | } |
439 | 453 | $s .= " [<strong>" . $row->count . "</strong>]</li>\n"; |
| 454 | + ++$counter; |
440 | 455 | } |
441 | 456 | $s .= '</ol>'; |
442 | 457 | $dbr->freeResult( $ret ); |
— | — | @@ -445,14 +460,13 @@ |
446 | 461 | } else if( isset($rangecount) && !$rangecount ) { |
447 | 462 | $s = wfMsgHtml("checkuser-nomatch")."\n"; |
448 | 463 | $wgOut->addHTML( $s ); |
449 | | - |
450 | 464 | return; |
451 | 465 | } |
452 | 466 | # OK, do the real query... |
453 | 467 | $use_index = $dbr->useIndexClause( $index ); |
454 | 468 | $sql = "SELECT cuc_namespace,cuc_title,cuc_user,cuc_user_text,cuc_comment,cuc_actiontext, |
455 | 469 | cuc_timestamp,cuc_minor,cuc_page_id,cuc_type,cuc_this_oldid,cuc_last_oldid,cuc_ip,cuc_xff,cuc_agent |
456 | | - FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds ORDER BY cuc_timestamp DESC LIMIT 5000"; |
| 470 | + FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds ORDER BY cuc_timestamp DESC LIMIT 5001"; |
457 | 471 | $ret = $dbr->query( $sql, __METHOD__ ); |
458 | 472 | |
459 | 473 | if( !$dbr->numRows( $ret ) ) { |
— | — | @@ -473,7 +487,12 @@ |
474 | 488 | # List out the edits |
475 | 489 | $s = '<div id="checkuserresults">'; |
476 | 490 | while( $row = $ret->fetchObject() ) { |
| 491 | + if( $counter >= 5000 ) { |
| 492 | + $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 493 | + break; |
| 494 | + } |
477 | 495 | $s .= $this->CUChangesLine( $row, $reason ); |
| 496 | + ++$counter; |
478 | 497 | } |
479 | 498 | $s .= '</ul></div>'; |
480 | 499 | $dbr->freeResult( $ret ); |
— | — | @@ -524,14 +543,22 @@ |
525 | 544 | # Ordered in descent by timestamp. Causes large filesorts if there are many edits. |
526 | 545 | # Check how many rows will need sorting ahead of time to see if this is too big. |
527 | 546 | # If it is, sort by IP,time to avoid the filesort. |
528 | | - $count = $dbr->estimateRowCount( 'cu_changes', '*', |
529 | | - array( $user_cond, $time_conds ), |
530 | | - __METHOD__, |
531 | | - array( 'USE INDEX' => 'cuc_user_ip_time' ) ); |
| 547 | + if( $period ) { |
| 548 | + $count = $dbr->selectField( 'cu_changes', 'COUNT(*)', |
| 549 | + array( $user_cond, $time_conds ), |
| 550 | + __METHOD__, |
| 551 | + array( 'USE INDEX' => 'cuc_user_ip_time' ) ); |
| 552 | + } else { |
| 553 | + $count = $dbr->estimateRowCount( 'cu_changes', '*', |
| 554 | + array( $user_cond, $time_conds ), |
| 555 | + __METHOD__, |
| 556 | + array( 'USE INDEX' => 'cuc_user_ip_time' ) ); |
| 557 | + } |
532 | 558 | # Cache common messages |
533 | 559 | $this->preCacheMessages(); |
534 | 560 | # See what is best to do after testing the waters... |
535 | | - if( $count > 3000 ) { |
| 561 | + if( $count > 5000 ) { |
| 562 | + $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
536 | 563 | $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
537 | 564 | $sql = "SELECT * FROM $cu_changes $use_index |
538 | 565 | WHERE $user_cond AND $time_conds |
— | — | @@ -565,6 +592,10 @@ |
566 | 593 | $wgOut->addHTML( $s ); |
567 | 594 | return; |
568 | 595 | } |
| 596 | + // Sorting might take some time...make sure it is there |
| 597 | + wfSuppressWarnings(); |
| 598 | + set_time_limit(60); |
| 599 | + wfRestoreWarnings(); |
569 | 600 | # OK, do the real query... |
570 | 601 | $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
571 | 602 | $sql = "SELECT * FROM $cu_changes $use_index |
— | — | @@ -652,12 +683,17 @@ |
653 | 684 | $sql = "SELECT cuc_ip_hex, COUNT(*) AS count, |
654 | 685 | MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
655 | 686 | FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds |
656 | | - GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5000"; |
| 687 | + GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
657 | 688 | $ret = $dbr->query( $sql, __METHOD__ ); |
658 | 689 | # List out each IP that has edits |
659 | 690 | $s = '<h5>' . wfMsg('checkuser-too-many') . '</h5>'; |
660 | 691 | $s .= '<ol>'; |
| 692 | + $counter = 0; |
661 | 693 | while( $row = $ret->fetchObject() ) { |
| 694 | + if( $counter >= 5000 ) { |
| 695 | + $wgOut->addHTML( wfMsgExt('checkuser-limited',array('parse')) ); |
| 696 | + break; |
| 697 | + } |
662 | 698 | # Convert the IP hexes into normal form |
663 | 699 | if( strpos($row->cuc_ip_hex,'v6-') !==false ) { |
664 | 700 | $ip = substr( $row->cuc_ip_hex, 3 ); |
— | — | @@ -675,6 +711,7 @@ |
676 | 712 | ' -- ' . $wgLang->timeanddate( $row->last, true ) . ') '; |
677 | 713 | } |
678 | 714 | $s .= " [<strong>" . $row->count . "</strong>]</li>\n"; |
| 715 | + ++$counter; |
679 | 716 | } |
680 | 717 | $s .= '</ol>'; |
681 | 718 | $dbr->freeResult( $ret ); |
— | — | @@ -692,7 +729,7 @@ |
693 | 730 | $use_index = $dbr->useIndexClause( $index ); |
694 | 731 | $sql = "SELECT cuc_user_text, cuc_timestamp, cuc_user, cuc_ip, cuc_agent, cuc_xff |
695 | 732 | FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds |
696 | | - ORDER BY cuc_timestamp DESC LIMIT 5000"; |
| 733 | + ORDER BY cuc_timestamp DESC LIMIT 10000"; |
697 | 734 | $ret = $dbr->query( $sql, __METHOD__ ); |
698 | 735 | |
699 | 736 | $users_first = $users_last = $users_edits = $users_ids = array(); |
Index: trunk/extensions/CheckUser/CheckUser.i18n.php |
— | — | @@ -62,6 +62,8 @@ |
63 | 63 | 'checkuser-ipeditcount' => '~$1 from all users', |
64 | 64 | 'checkuser-log-subpage' => 'Log', |
65 | 65 | 'checkuser-log-return' => 'Return to CheckUser main form', |
| 66 | + |
| 67 | + 'checkuser-limited' => '\'\'\'These results have been truncated for performance reasons.\'\'\'', |
66 | 68 | |
67 | 69 | 'checkuser-log-userips' => '$1 got IPs for $2', |
68 | 70 | 'checkuser-log-ipedits' => '$1 got edits for $2', |