Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/02/2017 04:39:49 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Queries: nopaging audit.

  • In r6506 the nopaging query argument was added to various queries to avoid paginating results when it wasn't necessary. This resulted in a few queries (widgets mainly) not obeying their specific settings.
  • In #3123, other inconsistencies in our query arguments were uncovered, triggering the need to audit our query usages and equalize them once again.

This change brings all queries back to par with one another, specifically in regards to posts_per_page => -1 style queries, and queries where filters can be suppressed and meta/term caches should not be primed.

It also groups together the get_user_object_ids functions. These are now unused in bbPress proper, though were previously useful before the engagements API was in place. These queries are considered too inefficient to rely upon in large-scale applications, but are included to provide filterable wrappers should someone need them, or should we need to bring them back later.

Props thebrandonallen. Fixes #3123.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/capabilities.php

    r6573 r6607  
    219219
    220220/**
    221  * Get array of forum IDs that a user can moderate
    222  *
    223  * @since 2.6.0 bbPress (r5834)
    224  *
    225  * @param int $user_id User id.
    226  *
    227  * @return boolean|array Return false on error or empty, or array of forum ids
    228  */
    229 function bbp_get_moderator_forum_ids( $user_id = 0 ) {
    230     $user_id = bbp_get_user_id( $user_id );
    231     $forums  = new WP_Query( array(
    232         'fields'        => 'ids',
    233         'post_type'     => bbp_get_forum_post_type(),
    234         'nopaging'      => true,
    235         'no_found_rows' => true,
    236         'meta_query'    => array( array(
    237             'key'     => '_bbp_moderator_id',
    238             'value'   => $user_id,
    239             'compare' => 'NUMERIC'
    240         ) )
    241     ) );
    242 
    243     // Filter & return
    244     return (array) apply_filters( 'bbp_get_moderator_forum_ids', $forums->posts, $user_id, $forums );
    245 }
    246 
    247 /**
    248221 * Can a user moderate a forum?
    249222 *
Note: See TracChangeset for help on using the changeset viewer.