Skip to:
Content

BuddyPress.org

Ticket #5629: bp-activity-classes.diff

File bp-activity-classes.diff, 1.6 KB (added by Clean-Cole, 6 years ago)

Patch for Ticket #5629

  • bp-activity-classes.php

     
    440440                        $activities   = self::get_activity_data( $activity_ids );
    441441                }
    442442
    443                 $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
    444                 $total_activities     = $wpdb->get_var( $total_activities_sql );
    445 
    446443                // Get the fullnames of users so we don't have to query in the loop
    447444                $activities = self::append_user_fullnames( $activities );
    448445
     
    465462                // Generate action strings
    466463                $activities = BP_Activity_Activity::generate_action_strings( $activities );
    467464
    468                 // If $max is set, only return up to the max results
    469                 if ( !empty( $max ) ) {
    470                         if ( (int) $total_activities > (int) $max )
    471                                 $total_activities = $max;
    472                 }
     465        // If $max is set, only return up to the max results
     466        if ( !empty( $max ) ) {
     467            $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
     468            $total_activities     = $wpdb->get_var( $total_activities_sql );
     469            if ( (int) $total_activities > (int) $max )
     470                $total_activities = $max;
     471        } else {
     472            $total_activities = 0;
     473        }
    473474
    474475                return array( 'activities' => $activities, 'total' => (int) $total_activities );
    475476        }