Ticket #4995: 4995.2.patch
File 4995.2.patch, 3.7 KB (added by , 12 years ago) |
---|
-
bp-activity-classes.php
170 170 // Searching 171 171 if ( $search_terms ) { 172 172 $search_terms = $wpdb->escape( $search_terms ); 173 $where_conditions['search_sql'] = "a.content LIKE '%%" . like_escape( $search_terms) . "%%'";173 $where_conditions['search_sql'] = "a.content LIKE '%%" . esc_sql( like_escape( $search_terms ) ) . "%%'"; 174 174 } 175 175 176 176 // Filtering … … 238 238 $total_activities = $wpdb->get_var( $total_activities_sql ); 239 239 240 240 // Get the fullnames of users so we don't have to query in the loop 241 $activity_user_ids = array(); 242 if ( bp_is_active( 'xprofile' ) && $activities ) { 243 foreach ( (array) $activities as $activity ) { 244 if ( (int) $activity->user_id ) 245 $activity_user_ids[] = $activity->user_id; 246 } 241 if ( bp_is_active( 'xprofile' ) && !empty( $activities ) ) { 242 $activity_user_ids = wp_list_pluck( $activities, 'user_id' ); 243 $activity_user_ids = implode( ',', wp_parse_id_list( $activity_user_ids ) ); 247 244 248 $activity_user_ids = implode( ',', array_unique( (array) $activity_user_ids ) ); 249 if ( !empty( $activity_user_ids ) ) { 245 if ( !empty( $activity_user_ids ) ) { 250 246 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})" ) ) { 251 247 foreach ( (array) $names as $name ) 252 248 $tmp_names[$name->user_id] = $name->user_fullname; … … 319 315 $where_args[] = $wpdb->prepare( "type = %s", $type ); 320 316 321 317 if ( !empty( $item_id ) ) 322 $where_args[] = $wpdb->prepare( "item_id = % s", $item_id );318 $where_args[] = $wpdb->prepare( "item_id = %d", $item_id ); 323 319 324 320 if ( !empty( $secondary_item_id ) ) 325 $where_args[] = $wpdb->prepare( "secondary_item_id = % s", $secondary_item_id );321 $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id ); 326 322 327 323 if ( !empty( $action ) ) 328 324 $where_args[] = $wpdb->prepare( "action = %s", $action ); … … 384 380 $where_args[] = $wpdb->prepare( "primary_link = %s", $primary_link ); 385 381 386 382 if ( !empty( $item_id ) ) 387 $where_args[] = $wpdb->prepare( "item_id = % s", $item_id );383 $where_args[] = $wpdb->prepare( "item_id = %d", $item_id ); 388 384 389 385 if ( !empty( $secondary_item_id ) ) 390 $where_args[] = $wpdb->prepare( "secondary_item_id = % s", $secondary_item_id );386 $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $secondary_item_id ); 391 387 392 388 if ( !empty( $date_recorded ) ) 393 389 $where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded ); … … 416 412 return $activity_ids; 417 413 } 418 414 419 function delete_activity_item_comments( $activity_ids ) {415 function delete_activity_item_comments( $activity_ids = array() ) { 420 416 global $bp, $wpdb; 421 417 422 if ( is_array( $activity_ids ) ) 423 $activity_ids = implode ( ',', array_map( 'absint', $activity_ids ) ); 424 else 425 $activity_ids = implode ( ',', array_map( 'absint', explode ( ',', $activity_ids ) ) ); 418 $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) ); 426 419 427 420 return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ); 428 421 } 429 422 430 function delete_activity_meta_entries( $activity_ids ) {423 function delete_activity_meta_entries( $activity_ids = array() ) { 431 424 global $bp, $wpdb; 432 425 433 if ( is_array( $activity_ids ) ) 434 $activity_ids = implode ( ',', array_map( 'absint', $activity_ids ) ); 435 else 436 $activity_ids = implode ( ',', array_map( 'absint', explode ( ',', $activity_ids ) ) ); 426 $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) ); 437 427 438 428 return $wpdb->query( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" ); 439 429 }