Skip to:
Content

BuddyPress.org

Opened 16 years ago

Closed 16 years ago

#296 closed defect (bug) (fixed)

Recent Blog Posts - duplicate entries

Reported by: gwrey's profile gwrey Owned by:
Milestone: Priority: minor
Severity: Version:
Component: Keywords:
Cc:

Description

BP_Blogs_Post::get_latest_posts()
returns duplicate entries if two different users updated the same post.

Fixed by using DISTINCT in the select

Change History (2)

#1 @jmax123
16 years ago

Same here - needs to be committed to trunk

In bp-blogs-classes.php

function get_latest_posts( $blog_id = null, $limit = 5 ) {

global $wpdb, $bp;


if ( $blog_id )

$blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );


$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM " . $bpblogs?table_name_blog_posts? . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );

for ( $i = 0; $i < count($post_ids); $i++ ) {

$posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);

}


return $posts;

}

#2 @apeatling
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.