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/topics/functions.php

    r6585 r6607  
    28822882    // Topic is being spammed, so its replies are trashed
    28832883    $replies = new WP_Query( array(
    2884         'suppress_filters' => true,
    2885         'post_type'        => bbp_get_reply_post_type(),
    2886         'post_status'      => bbp_get_public_status_id(),
    2887         'post_parent'      => $topic_id,
    2888         'posts_per_page'   => -1,
    2889         'nopaging'         => true,
    2890         'no_found_rows'    => true,
    2891         'fields'           => 'id=>parent'
     2884        'fields'         => 'id=>parent',
     2885        'post_type'      => bbp_get_reply_post_type(),
     2886        'post_status'    => bbp_get_public_status_id(),
     2887        'post_parent'    => $topic_id,
     2888        'posts_per_page' => -1,
     2889
     2890        // Performance
     2891        'nopaging'               => true,
     2892        'suppress_filters'       => true,
     2893        'update_post_term_cache' => false,
     2894        'update_post_meta_cache' => false,
     2895        'ignore_sticky_posts'    => true,
     2896        'no_found_rows'          => true
    28922897    ) );
    28932898
     
    29152920/**
    29162921 * Store the tags to a topic in post meta before it's marked as spam so they
    2917  * can be retreived and unspammed later.
     2922 * can be retrieved and unspammed later.
    29182923 *
    29192924 * Usually you'll want to do this before the topic itself is marked as spam.
     
    32733278    // Note that we get all post statuses here
    32743279    $replies = new WP_Query( array(
    3275         'suppress_filters' => true,
    3276         'post_type'        => bbp_get_reply_post_type(),
    3277         'post_status'      => array_keys( get_post_stati() ),
    3278         'post_parent'      => $topic_id,
    3279         'posts_per_page'   => -1,
    3280         'nopaging'         => true,
    3281         'no_found_rows'    => true,
    3282         'fields'           => 'id=>parent'
     3280        'fields'         => 'id=>parent',
     3281        'post_type'      => bbp_get_reply_post_type(),
     3282        'post_status'    => array_keys( get_post_stati() ),
     3283        'post_parent'    => $topic_id,
     3284        'posts_per_page' => -1,
     3285
     3286        // Performance
     3287        'nopaging'               => true,
     3288        'suppress_filters'       => true,
     3289        'update_post_term_cache' => false,
     3290        'update_post_meta_cache' => false,
     3291        'ignore_sticky_posts'    => true,
     3292        'no_found_rows'          => true
    32833293    ) );
    32843294
     
    33293339    // Topic is being trashed, so its replies are trashed too
    33303340    $replies = new WP_Query( array(
    3331         'suppress_filters' => true,
    3332         'post_type'        => bbp_get_reply_post_type(),
    3333         'post_status'      => bbp_get_public_status_id(),
    3334         'post_parent'      => $topic_id,
    3335         'posts_per_page'   => -1,
    3336         'nopaging'         => true,
    3337         'no_found_rows'    => true,
    3338         'fields'           => 'id=>parent'
     3341        'fields'         => 'id=>parent',
     3342        'post_type'      => bbp_get_reply_post_type(),
     3343        'post_status'    => bbp_get_public_status_id(),
     3344        'post_parent'    => $topic_id,
     3345        'posts_per_page' => -1,
     3346
     3347        // Performance
     3348        'nopaging'               => true,
     3349        'suppress_filters'       => true,
     3350        'update_post_term_cache' => false,
     3351        'update_post_meta_cache' => false,
     3352        'ignore_sticky_posts'    => true,
     3353        'no_found_rows'          => true
    33393354    ) );
    33403355
Note: See TracChangeset for help on using the changeset viewer.