Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -24,7 +24,6 @@ |
25 | 25 | global $wgRequest, $wgOut, $wgUser, $wgContLang; |
26 | 26 | |
27 | 27 | $this->setHeaders(); |
28 | | - $this->sk = $wgUser->getSkin(); |
29 | 28 | |
30 | 29 | // This is horribly shitty. |
31 | 30 | // Lacking formal aliases, it's tough to ensure we have compatibility. |
— | — | @@ -587,13 +586,17 @@ |
588 | 587 | $counter = 0; |
589 | 588 | # See what is best to do after testing the waters... |
590 | 589 | if ( isset( $rangecount ) && $rangecount > 5000 ) { |
591 | | - $use_index = $dbr->useIndexClause( $index ); |
592 | | - $sql = "SELECT cuc_ip_hex, COUNT(*) AS count, |
593 | | - MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
594 | | - FROM $cu_changes $use_index |
595 | | - WHERE $ip_conds AND $time_conds |
596 | | - GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
597 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
| 590 | + $ret = $dbr->select( 'cu_changes', |
| 591 | + array( 'cuc_ip_hex', 'COUNT(*) AS count', 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp AS last' ), |
| 592 | + array( $ip_conds, $time_conds ), |
| 593 | + __METHOD___, |
| 594 | + array( |
| 595 | + 'GROUP BY' => 'cuc_ip_hex', |
| 596 | + 'ORDER BY' => 'cuc_ip_hex', |
| 597 | + 'LIMIT' => 5001, |
| 598 | + 'USE INDEX' => $index, |
| 599 | + ) |
| 600 | + ); |
598 | 601 | # List out each IP that has edits |
599 | 602 | $s = wfMsgExt( 'checkuser-too-many', array( 'parse' ) ); |
600 | 603 | $s .= '<ol>'; |
— | — | @@ -631,13 +634,24 @@ |
632 | 635 | $wgOut->addHTML( $s ); |
633 | 636 | return; |
634 | 637 | } |
| 638 | + |
635 | 639 | # OK, do the real query... |
636 | | - $use_index = $dbr->useIndexClause( $index ); |
637 | | - $sql = "SELECT cuc_namespace,cuc_title,cuc_user,cuc_user_text,cuc_comment,cuc_actiontext, |
638 | | - cuc_timestamp,cuc_minor,cuc_page_id,cuc_type,cuc_this_oldid,cuc_last_oldid,cuc_ip,cuc_xff,cuc_agent |
639 | | - FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds ORDER BY cuc_timestamp DESC LIMIT 5001"; |
640 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
641 | 640 | |
| 641 | + $ret = $dbr->select( |
| 642 | + 'cu_changes', |
| 643 | + array( 'cuc_namespace','cuc_title', 'cuc_user', 'cuc_user_text', 'cuc_comment', 'cuc_actiontext', |
| 644 | + 'cuc_timestamp', 'cuc_minor', 'cuc_page_id', 'cuc_type', 'cuc_this_oldid', |
| 645 | + 'cuc_last_oldid', 'cuc_ip', 'cuc_xff','cuc_agent' |
| 646 | + ), |
| 647 | + array( $ip_conds, $time_conds ), |
| 648 | + __METHOD__, |
| 649 | + array( |
| 650 | + 'ORDER BY' => 'cuc_timestamp DESC', |
| 651 | + 'LIMIT' => 5001, |
| 652 | + 'USE INDEX' => $index, |
| 653 | + ) |
| 654 | + ); |
| 655 | + |
642 | 656 | if ( !$dbr->numRows( $ret ) ) { |
643 | 657 | $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
644 | 658 | } else { |
— | — | @@ -706,7 +720,7 @@ |
707 | 721 | $dbr = wfGetDB( DB_SLAVE ); |
708 | 722 | $user_cond = "cuc_user = '$user_id'"; |
709 | 723 | $time_conds = $this->getTimeConds( $period ); |
710 | | - $cu_changes = $dbr->tableName( 'cu_changes' ); |
| 724 | + $cu_changes = $dbr->tableName( '' ); |
711 | 725 | # Ordered in descent by timestamp. Causes large filesorts if there are many edits. |
712 | 726 | # Check how many rows will need sorting ahead of time to see if this is too big. |
713 | 727 | # If it is, sort by IP,time to avoid the filesort. |
— | — | @@ -726,11 +740,18 @@ |
727 | 741 | # See what is best to do after testing the waters... |
728 | 742 | if ( $count > 5000 ) { |
729 | 743 | $wgOut->addHTML( wfMsgExt( 'checkuser-limited', array( 'parse' ) ) ); |
730 | | - $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
731 | | - $sql = "SELECT * FROM $cu_changes $use_index |
732 | | - WHERE $user_cond AND $time_conds |
733 | | - ORDER BY cuc_ip ASC, cuc_timestamp DESC LIMIT 5000"; |
734 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
| 744 | + |
| 745 | + $ret = $dbr->select( |
| 746 | + 'cu_changes', |
| 747 | + '*', |
| 748 | + array( $user_cond, $time_conds ), |
| 749 | + __METHOD__, |
| 750 | + array( |
| 751 | + 'ORDER BY' => 'cuc_ip ASC, cuc_timestamp DESC', |
| 752 | + 'LIMIT' => 5000, |
| 753 | + 'USE INDEX' => 'cuc_user_ip_time' |
| 754 | + ) |
| 755 | + ); |
735 | 756 | # Try to optimize this query |
736 | 757 | $lb = new LinkBatch; |
737 | 758 | foreach ( $ret as $row ) { |
— | — | @@ -762,12 +783,20 @@ |
763 | 784 | wfSuppressWarnings(); |
764 | 785 | set_time_limit( 60 ); |
765 | 786 | wfRestoreWarnings(); |
| 787 | + |
766 | 788 | # OK, do the real query... |
767 | | - $use_index = $dbr->useIndexClause( 'cuc_user_ip_time' ); |
768 | | - $sql = "SELECT * FROM $cu_changes $use_index |
769 | | - WHERE $user_cond AND $time_conds ORDER BY cuc_timestamp DESC LIMIT 5000"; |
770 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
771 | 789 | |
| 790 | + $ret = $dbr->select( |
| 791 | + 'cu_changes', |
| 792 | + '*', |
| 793 | + array( $user_cond, $time_conds ), |
| 794 | + __METHOD__, |
| 795 | + array( |
| 796 | + 'ORDER BY' => 'cuc_timestamp DESC', |
| 797 | + 'LIMIT' => 5000, |
| 798 | + 'USE INDEX' => 'cuc_user_ip_time' |
| 799 | + ) |
| 800 | + ); |
772 | 801 | if ( !$dbr->numRows( $ret ) ) { |
773 | 802 | $s = $this->noMatchesMessage( $user ) . "\n"; |
774 | 803 | } else { |