Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -790,10 +790,13 @@ |
791 | 791 | $types = ($types === '') ? array() : (array)$types; |
792 | 792 | // Don't even show header for private logs; don't recognize it... |
793 | 793 | foreach ( $types as $type ) { |
794 | | - if( isset( $wgLogRestrictions[$type] ) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) { |
| 794 | + if( isset( $wgLogRestrictions[$type] ) |
| 795 | + && !$wgUser->isAllowed($wgLogRestrictions[$type]) |
| 796 | + ) { |
795 | 797 | $types = array_diff( $types, array( $type ) ); |
796 | 798 | } |
797 | 799 | } |
| 800 | + $this->types = $types; |
798 | 801 | // Don't show private logs to unprivileged users. |
799 | 802 | // Also, only show them upon specific request to avoid suprises. |
800 | 803 | $audience = $types ? 'user' : 'public'; |
— | — | @@ -802,7 +805,6 @@ |
803 | 806 | $this->mConds[] = $hideLogs; |
804 | 807 | } |
805 | 808 | if( count($types) ) { |
806 | | - $this->types = $types; |
807 | 809 | $this->mConds['log_type'] = $types; |
808 | 810 | // Set typeCGI; used in url param for paging |
809 | 811 | if( count($types) == 1 ) $this->typeCGI = $types[0]; |
— | — | @@ -890,18 +892,25 @@ |
891 | 893 | $tables = array( 'logging', 'user' ); |
892 | 894 | $this->mConds[] = 'user_id = log_user'; |
893 | 895 | $groupBy = false; |
| 896 | + $index = array(); |
894 | 897 | # Add log_search table if there are conditions on it |
895 | 898 | if( array_key_exists('ls_field',$this->mConds) ) { |
896 | 899 | $tables[] = 'log_search'; |
897 | | - $index = array( 'log_search' => 'ls_field_val', 'logging' => 'PRIMARY' ); |
| 900 | + $index['log_search'] = 'ls_field_val'; |
| 901 | + $index['logging'] = 'PRIMARY'; |
898 | 902 | $groupBy = 'ls_log_id'; |
899 | | - # Don't use the wrong logging index |
| 903 | + # Avoid usage of the wrong index by limiting |
| 904 | + # the choices of available indexes. This mainly |
| 905 | + # avoids site-breaking filesorts. |
900 | 906 | } else if( $this->title || $this->pattern || $this->user ) { |
901 | | - $index = array( 'logging' => array('page_time','user_time') ); |
902 | | - } else if( $this->types ) { |
903 | | - $index = array( 'logging' => 'type_time' ); |
| 907 | + $index['logging'] = array( 'page_time', 'user_time' ); |
| 908 | + if( count($this->types) == 1 ) { |
| 909 | + $index['logging'][] = 'log_user_type_time'; |
| 910 | + } |
| 911 | + } else if( count($this->types) == 1 ) { |
| 912 | + $index['logging'] = 'type_time'; |
904 | 913 | } else { |
905 | | - $index = array( 'logging' => 'times' ); |
| 914 | + $index['logging'] = 'times'; |
906 | 915 | } |
907 | 916 | $options = array( 'USE INDEX' => $index ); |
908 | 917 | # Don't show duplicate rows when using log_search |