Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/31/2014 09:27:11 PM (11 years ago)
Author:
boonebgorges
Message:

When prefetching group data for an activity loop, avoid the query when there's nothing to fetch

When there are no uncached_ids, don't attempt to query. There's nothing to get,
and it will result in an invalidly formatted SQL query.

Fixes #5503

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-activity.php

    r8127 r8224  
    144144        }
    145145
    146         global $wpdb, $bp;
    147         $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
    148         $groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" );
    149         foreach ( $groups as $group ) {
    150             wp_cache_set( $group->id, $group, 'bp_groups' );
     146        if ( ! empty( $uncached_ids ) ) {
     147            global $wpdb, $bp;
     148            $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
     149            $groups = $wpdb->get_results( "SELECT * FROM {$bp->groups->table_name} WHERE id IN ({$uncached_ids_sql})" );
     150            foreach ( $groups as $group ) {
     151                wp_cache_set( $group->id, $group, 'bp_groups' );
     152            }
    151153        }
    152154    }
Note: See TracChangeset for help on using the changeset viewer.