Skip to:
Content

BuddyPress.org

Ticket #445: randomblog2.patch

File randomblog2.patch, 1.6 KB (added by burtadsit, 15 years ago)

Actual patch to fix random blog bug. Ignore the other patch this is the real one.

  • bp-blogs-classes.php

     
    187187               
    188188                if ( $limit && $page ) {
    189189                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    190                         $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand()" ) );
     190                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand(){$pag_sql}" ) );
    191191                }
    192192               
    193                 $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$pag_sql}" ) );               
    194                
     193                $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand(){$pag_sql}" ) );                 
    195194                return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
    196195        }
    197196