Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/04/2012 12:03:40 PM (13 years ago)
Author:
djpaul
Message:

Fix alot of WPDB->Prepare() warnings in the 1.6 branch. See #4654

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6/bp-activity/bp-activity-classes.php

    r6330 r6557  
    217217
    218218        if ( !empty( $the_index ) ) {
    219             $index_hint_sql = $wpdb->prepare( "USE INDEX ({$the_index})" );
     219            $index_hint_sql = "USE INDEX ({$the_index})";
    220220        } else {
    221221            $index_hint_sql = '';
     
    229229
    230230            $pag_sql    = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
    231             $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 ) );
     231            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
    232232        } else {
    233             $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 ) );
    234         }
    235 
    236         $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort );
     233            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) );
     234        }
     235
     236        $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $where_sql, $sort );
    237237
    238238        $total_activities = $wpdb->get_var( $total_activities_sql );
     
    248248            $activity_user_ids = implode( ',', array_unique( (array) $activity_user_ids ) );
    249249            if ( !empty( $activity_user_ids ) ) {
    250                 if ( $names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) ) {
     250                if ( $names = $wpdb->get_results( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) {
    251251                    foreach ( (array) $names as $name )
    252252                        $tmp_names[$name->user_id] = $name->user_fullname;
     
    402402
    403403        // Fetch the activity IDs so we can delete any comments for this activity item
    404         $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ) );
    405 
    406         if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) )
     404        $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
     405
     406        if ( !$wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) )
    407407            return false;
    408408
     
    425425            $activity_ids = implode ( ',', array_map( 'absint', explode ( ',', $activity_ids ) ) );
    426426
    427         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ) );
     427        return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
    428428    }
    429429
     
    436436            $activity_ids = implode ( ',', array_map( 'absint', explode ( ',', $activity_ids ) ) );
    437437
    438         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" ) );
     438        return $wpdb->query( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" );
    439439    }
    440440
     
    561561        global $wpdb, $bp;
    562562
    563         return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" ) );
     563        return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
    564564    }
    565565
     
    648648        global $bp, $wpdb;
    649649
    650         return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" ) );
     650        return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
    651651    }
    652652
Note: See TracChangeset for help on using the changeset viewer.