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

    r6586 r6607  
    14721472
    14731473    $query = new WP_Query( array(
    1474         'fields'      => 'ids',
    1475         'post_parent' => $parent_id,
    1476         'post_status' => $post_status,
    1477         'post_type'   => $post_type,
    1478         'orderby'     => array(
     1474        'fields'         => 'ids',
     1475        'post_parent'    => $parent_id,
     1476        'post_status'    => $post_status,
     1477        'post_type'      => $post_type,
     1478        'posts_per_page' => 1,
     1479        'orderby'        => array(
    14791480            'post_date' => 'DESC',
    14801481            'ID'        => 'DESC'
    14811482        ),
    14821483
    1483         // Maybe change these later
    1484         'posts_per_page'         => 1,
     1484        // Performance
     1485        'suppress_filters'       => true,
    14851486        'update_post_term_cache' => false,
    14861487        'update_post_meta_cache' => false,
     
    15081509
    15091510    // Bail if nothing passed
    1510     if ( empty( $parent_id ) ) {
     1511    if ( empty( $parent_id ) || empty( $post_type ) ) {
    15111512        return false;
    15121513    }
     
    15211522
    15221523    $query = new WP_Query( array(
    1523         'fields'      => 'ids',
    1524         'post_parent' => $parent_id,
    1525         'post_status' => $post_status,
    1526         'post_type'   => $post_type,
    1527 
    1528         // Maybe change these later
    1529         'posts_per_page'         => -1,
     1524        'fields'         => 'ids',
     1525        'post_parent'    => $parent_id,
     1526        'post_status'    => $post_status,
     1527        'post_type'      => $post_type,
     1528        'posts_per_page' => -1,
     1529
     1530        // Performance
     1531        'nopaging'               => true,
     1532        'suppress_filters'       => true,
    15301533        'update_post_term_cache' => false,
    15311534        'update_post_meta_cache' => false,
     
    15671570
    15681571    $query = new WP_Query( array(
    1569         'fields'           => 'ids',
    1570         'suppress_filters' => true,
    1571         'post_parent'      => $parent_id,
    1572         'post_status'      => $post_status,
    1573         'post_type'        => $post_type,
    1574         'posts_per_page'   => -1,
    1575 
    1576         // Maybe change these later
     1572        'fields'         => 'ids',
     1573        'post_parent'    => $parent_id,
     1574        'post_status'    => $post_status,
     1575        'post_type'      => $post_type,
     1576        'posts_per_page' => -1,
     1577        'orderby'        => array(
     1578            'post_date' => 'DESC',
     1579            'ID'        => 'DESC'
     1580        ),
     1581
     1582        // Performance
     1583        'nopaging'               => true,
     1584        'suppress_filters'       => true,
    15771585        'update_post_term_cache' => false,
    15781586        'update_post_meta_cache' => false,
    15791587        'ignore_sticky_posts'    => true,
    1580         'no_found_rows'          => true,
    1581         'nopaging'               => true
     1588        'no_found_rows'          => true
    15821589    ) );
    15831590    $child_ids = ! empty( $query->posts ) ? $query->posts : array();
Note: See TracChangeset for help on using the changeset viewer.