diff --git bp-activity/bp-activity-classes.php bp-activity/bp-activity-classes.php
index 05baf93..5f0dc97 100644
|
|
class BP_Activity_Activity { |
162 | 162 | $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) ); |
163 | 163 | $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ), $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ); |
164 | 164 | } else { |
165 | | $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $select_sql, $from_sql, $where_sql, $sort ) ); |
| 165 | $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$index_hint_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $select_sql, $from_sql, $where_sql, $sort ) ); |
| 166 | } |
| 167 | |
| 168 | $indexes = array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ); |
| 169 | |
| 170 | foreach( $indexes as $key => $index ) { |
| 171 | if ( false !== strpos( $where_sql, $index ) ) { |
| 172 | $the_index = $index; |
| 173 | break; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if ( !empty( $the_index ) ) { |
| 178 | $index_hint_sql = $wpdb->prepare( "USE INDEX ({$the_index})" ); |
| 179 | } else { |
| 180 | $index_hint_sql = ''; |
166 | 181 | } |
167 | 182 | |
168 | | $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort ); |
| 183 | $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(*) FROM {$bp->activity->table_name} a {$index_hint_sql} {$where_sql}" ), $where_sql, $sort ); |
169 | 184 | |
170 | 185 | $total_activities = $wpdb->get_var( $total_activities_sql ); |
171 | 186 | |