Skip to:
Content

bbPress.org

Changeset 6612


Ignore:
Timestamp:
07/04/2017 03:54:06 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Queries: Use new object_type over old post_type.

When bbp_get_user_object_ids() was introduced, some helpers did not get updated to use the new argument key. This change fixes that, and fixes failing tests in the process.

Note that these tests are testing new & unused helper functions for 2.6, so it's unlikely any noticable problems occurred from these being broken.

Location:
trunk/src/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/search/template.php

    r6573 r6612  
    4848
    4949        // Default view=all statuses
    50         $post_statuses = array(
    51             bbp_get_public_status_id(),
    52             bbp_get_closed_status_id(),
    53             bbp_get_spam_status_id(),
    54             bbp_get_trash_status_id(),
    55             bbp_get_pending_status_id()
    56         );
     50        $post_statuses = array_keys( bbp_get_topic_statuses() );
    5751
    5852        // Add support for private status
  • trunk/src/includes/topics/functions.php

    r6607 r6612  
    18241824    // Filter & return
    18251825    return (array) apply_filters( 'bbp_get_topic_statuses', array(
    1826         bbp_get_public_status_id()  => _x( 'Open',    'Open the topic',        'bbpress' ),
    1827         bbp_get_closed_status_id()  => _x( 'Closed',  'Close the topic',       'bbpress' ),
    1828         bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the topic',        'bbpress' ),
    1829         bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the topic',       'bbpress' ),
    1830         bbp_get_pending_status_id() => _x( 'Pending', 'Mark topic as pending', 'bbpress' ),
     1826        bbp_get_public_status_id()  => _x( 'Open',    'Open the topic',      'bbpress' ),
     1827        bbp_get_closed_status_id()  => _x( 'Closed',  'Close the topic',     'bbpress' ),
     1828        bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the topic',      'bbpress' ),
     1829        bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the topic',     'bbpress' ),
     1830        bbp_get_pending_status_id() => _x( 'Pending', 'Unapprove the topic', 'bbpress' )
    18311831    ), $topic_id );
    18321832}
  • trunk/src/includes/users/engagements.php

    r6607 r6612  
    960960
    961961    // Parse arguments
    962     $r = bbp_parse_args( $r['args'], $defaults, "get_{$r['filter']}_args" );
     962    $query_args = bbp_parse_args( $r['args'], $defaults, "get_{$r['filter']}_args" );
    963963
    964964    // Queries
    965965    if ( 'post' === $r['meta_type'] ) {
    966         $query      = new WP_Query( $r );
     966        $query      = new WP_Query( $query_args );
    967967        $object_ids = $query->posts;
    968968    }
     
    983983function bbp_get_moderator_forum_ids( $user_id = 0 ) {
    984984    return bbp_get_user_object_ids( array(
    985         'user_id'   => $user_id,
    986         'meta_key'  => '_bbp_moderator_id',
    987         'post_type' => bbp_get_forum_post_type(),
    988         'filter'    => 'moderator_forum_ids'
     985        'user_id'     => $user_id,
     986        'meta_key'    => '_bbp_moderator_id',
     987        'object_type' => bbp_get_forum_post_type(),
     988        'filter'      => 'moderator_forum_ids'
    989989    ) );
    990990}
     
    10351035function bbp_get_user_subscribed_forum_ids( $user_id = 0 ) {
    10361036    return bbp_get_user_object_ids( array(
    1037         'user_id'   => $user_id,
    1038         'meta_key'  => '_bbp_subscription',
    1039         'post_type' => bbp_get_forum_post_type(),
    1040         'filter'    => 'user_subscribed_forum_ids'
     1037        'user_id'     => $user_id,
     1038        'meta_key'    => '_bbp_subscription',
     1039        'object_type' => bbp_get_forum_post_type(),
     1040        'filter'      => 'user_subscribed_forum_ids'
    10411041    ) );
    10421042}
  • trunk/src/includes/users/functions.php

    r6611 r6612  
    648648    $user_id = bbp_get_user_id( $user_id );
    649649    $bbp_db  = bbp_db();
     650    $statii  = "'" . implode( "', '", bbp_get_public_topic_statuses() ) . "'";
    650651    $sql     = "SELECT COUNT(*)
    651652            FROM {$bbp_db->posts}
    652653            WHERE post_author = %d
    653654                AND post_type = %s
    654                 AND post_status = %s";
    655 
    656     $query   = $bbp_db->prepare( $sql, $user_id, bbp_get_reply_post_type(), bbp_get_public_status_id() );
     655                AND post_status IN ({$statii})";
     656
     657    $query   = $bbp_db->prepare( $sql, $user_id, bbp_get_reply_post_type() );
    657658    $count   = (int) $bbp_db->get_var( $query );
    658659
Note: See TracChangeset for help on using the changeset viewer.