Skip to:
Content

bbPress.org

Changeset 2502


Ignore:
Timestamp:
07/23/2010 04:03:35 AM (16 years ago)
Author:
chrishajer
Message:

Fix order of posts and remove duplicates, using a regex. Fixes #1301. Props Nightgunner5

Location:
trunk/bb-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.bb-meta.php

    r2475 r2502  
    297297            break;
    298298        case 'version':
    299             return '1.1-alpha-2475'; // Don't filter
     299            return '1.1-alpha-2501'; // Don't filter
    300300            break;
    301301        case 'bb_db_version' :
  • trunk/bb-includes/functions.bb-posts.php

    r2475 r2502  
    206206    $the_posts = array_merge( $_cached_posts, $_query_posts );
    207207
     208    global $bb_cache_posts_sort_by;
     209    $bb_cache_posts_sort_by = 'post_id';
     210    if ( isset( $_query ) && preg_match( '/ORDER\s+BY\s+`?(?:p\.)?(.+?)(?:[`,\s]|$)/i', $_query, $order_by ) )
     211        $bb_cache_posts_sort_by = $order_by[1];
    208212    usort( $the_posts, '_bb_cache_posts_sort' );
    209     if ( isset( $_query ) && strpos( $_query, 'DESC' ) !== false )
     213    if ( isset( $_query ) && stripos( $_query, 'DESC' ) !== false )
    210214        $the_posts = array_reverse( $the_posts );
    211215
     
    214218
    215219function _bb_cache_posts_sort( $a, $b ) {
    216     return (int) $a->post_id - (int) $b->post_id;
     220    global $bb_cache_posts_sort_by;
     221
     222    if ( $a->$bb_cache_posts_sort_by > $b->$bb_cache_posts_sort_by )
     223        return 1;
     224    if ( $a->$bb_cache_posts_sort_by < $b->$bb_cache_posts_sort_by )
     225        return -1;
     226    return 0;
    217227}
    218228
Note: See TracChangeset for help on using the changeset viewer.