Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | protected function preCacheMessages() { |
123 | 123 | // Precache various messages |
124 | 124 | if ( !isset( $this->message ) ) { |
125 | | - foreach ( explode( ' ', 'diff hist minoreditletter newpageletter blocklink log' ) as $msg ) { |
| 125 | + foreach ( array( 'diff', 'hist', 'minoreditletter', 'newpageletter', 'blocklink', 'log' ) as $msg ) { |
126 | 126 | $this->message[$msg] = wfMsgExt( $msg, array( 'escape' ) ); |
127 | 127 | } |
128 | 128 | } |
— | — | @@ -560,7 +560,6 @@ |
561 | 561 | |
562 | 562 | $ip_conds = $dbr->makeList( $ip_conds, LIST_AND ); |
563 | 563 | $time_conds = $this->getTimeConds( $period ); |
564 | | - $cu_changes = $dbr->tableName( 'cu_changes' ); |
565 | 564 | # Ordered in descent by timestamp. Can cause large filesorts on range scans. |
566 | 565 | # Check how many rows will need sorting ahead of time to see if this is too big. |
567 | 566 | # Also, if we only show 5000, too many will be ignored as well. |
— | — | @@ -587,7 +586,7 @@ |
588 | 587 | # See what is best to do after testing the waters... |
589 | 588 | if ( isset( $rangecount ) && $rangecount > 5000 ) { |
590 | 589 | $ret = $dbr->select( 'cu_changes', |
591 | | - array( 'cuc_ip_hex', 'COUNT(*) AS count', 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp AS last' ), |
| 590 | + array( 'cuc_ip_hex', 'COUNT(*) AS count', 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp) AS last' ), |
592 | 591 | array( $ip_conds, $time_conds ), |
593 | 592 | __METHOD___, |
594 | 593 | array( |
— | — | @@ -639,9 +638,10 @@ |
640 | 639 | |
641 | 640 | $ret = $dbr->select( |
642 | 641 | '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' |
| 642 | + array( |
| 643 | + '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 | 646 | ), |
647 | 647 | array( $ip_conds, $time_conds ), |
648 | 648 | __METHOD__, |
— | — | @@ -720,7 +720,6 @@ |
721 | 721 | $dbr = wfGetDB( DB_SLAVE ); |
722 | 722 | $user_cond = "cuc_user = '$user_id'"; |
723 | 723 | $time_conds = $this->getTimeConds( $period ); |
724 | | - $cu_changes = $dbr->tableName( '' ); |
725 | 724 | # Ordered in descent by timestamp. Causes large filesorts if there are many edits. |
726 | 725 | # Check how many rows will need sorting ahead of time to see if this is too big. |
727 | 726 | # If it is, sort by IP,time to avoid the filesort. |
— | — | @@ -850,7 +849,6 @@ |
851 | 850 | |
852 | 851 | $ip_conds = $dbr->makeList( $ip_conds, LIST_AND ); |
853 | 852 | $time_conds = $this->getTimeConds( $period ); |
854 | | - $cu_changes = $dbr->tableName( 'cu_changes' ); |
855 | 853 | $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time'; |
856 | 854 | # Ordered in descent by timestamp. Can cause large filesorts on range scans. |
857 | 855 | # Check how many rows will need sorting ahead of time to see if this is too big. |
— | — | @@ -874,12 +872,21 @@ |
875 | 873 | } |
876 | 874 | // Are there too many edits? |
877 | 875 | if ( isset( $rangecount ) && $rangecount > 10000 ) { |
878 | | - $use_index = $dbr->useIndexClause( $index ); |
879 | | - $sql = "SELECT cuc_ip_hex, COUNT(*) AS count, |
880 | | - MIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last |
881 | | - FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds |
882 | | - GROUP BY cuc_ip_hex ORDER BY cuc_ip_hex LIMIT 5001"; |
883 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
| 876 | + $ret = $dbr->select( |
| 877 | + 'cu_changes', |
| 878 | + array( |
| 879 | + 'cuc_ip_hex', 'COUNT(*) AS count', |
| 880 | + 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp) AS last' |
| 881 | + ), |
| 882 | + array( $ip_conds, $time_conds ), |
| 883 | + __METHOD__, |
| 884 | + array( |
| 885 | + 'GROUP BY' => 'cuc_ip_hex', |
| 886 | + 'ORDER BY' => 'cuc_ip_hex', |
| 887 | + 'LIMIT' => 5001, |
| 888 | + 'USE INDEX' => $index, |
| 889 | + ) |
| 890 | + ); |
884 | 891 | # List out each IP that has edits |
885 | 892 | $s = '<h5>' . wfMsg( 'checkuser-too-many' ) . '</h5>'; |
886 | 893 | $s .= '<ol>'; |
— | — | @@ -920,18 +927,27 @@ |
921 | 928 | |
922 | 929 | global $wgMemc; |
923 | 930 | # OK, do the real query... |
924 | | - $use_index = $dbr->useIndexClause( $index ); |
925 | | - $sql = "SELECT cuc_user_text, cuc_timestamp, cuc_user, cuc_ip, cuc_agent, cuc_xff |
926 | | - FROM $cu_changes $use_index WHERE $ip_conds AND $time_conds |
927 | | - ORDER BY cuc_timestamp DESC LIMIT 10000"; |
928 | | - $ret = $dbr->query( $sql, __METHOD__ ); |
929 | 931 | |
| 932 | + $ret = $dbr->select( |
| 933 | + 'cu_changes', |
| 934 | + array( |
| 935 | + 'cuc_user_text', 'cuc_timestamp', 'cuc_user', 'cuc_ip', 'cuc_agent', 'cuc_xff' |
| 936 | + ), |
| 937 | + array( $ip_conds, $time_conds ), |
| 938 | + __METHOD__, |
| 939 | + array( |
| 940 | + 'ORDER BY' => 'cuc_timestamp DESC', |
| 941 | + 'LIMIT' => 10000, |
| 942 | + 'USE INDEX' => $index, |
| 943 | + ) |
| 944 | + ); |
| 945 | + |
930 | 946 | $users_first = $users_last = $users_edits = $users_ids = array(); |
931 | 947 | if ( !$dbr->numRows( $ret ) ) { |
932 | 948 | $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
933 | 949 | } else { |
934 | 950 | global $wgAuth; |
935 | | - while ( ( $row = $dbr->fetchObject( $ret ) ) != false ) { |
| 951 | + foreach( $ret as $row ) { |
936 | 952 | if ( !array_key_exists( $row->cuc_user_text, $users_edits ) ) { |
937 | 953 | $users_last[$row->cuc_user_text] = $row->cuc_timestamp; |
938 | 954 | $users_edits[$row->cuc_user_text] = 0; |