WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/28/2016 03:09:09 AM (4 years ago)
Author:
boonebgorges
Message:

Allow term meta lazy-loading to be selectively disabled in WP_Query.

The process of lazy-loading can be resource intensive for object that have
terms in large numbers of taxonomies and are running a persistent object cache.
This new parameter allows the feature to be disabled in these cases.

Props DBrumbaugh10Up.
See #36953.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r37544 r37589  
    14691469     *              Introduced the `$comment_status` and `$ping_status` parameters.
    14701470     *              Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts.
    1471      * @since 4.6.0 Added 'post_name__in' support for `$orderby`.
     1471     * @since 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced `$lazy_load_term_meta`.
    14721472     * @access public
    14731473     *
     
    15681568     *     @type bool         $update_post_meta_cache  Whether to update the post meta cache. Default true.
    15691569     *     @type bool         $update_post_term_cache  Whether to update the post term cache. Default true.
     1570     *     @type bool         $lazy_load_term_meta     Whether to lazy-load term meta. Setting to false will
     1571     *                                                 disable cache priming for term meta, so that each
     1572     *                                                 get_term_meta() call will hit the database.
     1573     *                                                 Defaults to the value of `$update_post_term_cache`.
    15701574     *     @type int          $w                       The week number of the year. Default empty. Accepts numbers 0-53.
    15711575     *     @type int          $year                    The four-digit year. Default empty. Accepts any four-digit year.
     
    25462550            $q['update_post_term_cache'] = true;
    25472551
     2552        if ( ! isset( $q['lazy_load_term_meta'] ) ) {
     2553            $q['lazy_load_term_meta'] = $q['update_post_term_cache'];
     2554        }
     2555
    25482556        if ( !isset($q['update_post_meta_cache']) )
    25492557            $q['update_post_meta_cache'] = true;
     
    37833791        }
    37843792
    3785         if ( $q['update_post_term_cache'] ) {
     3793        if ( $q['lazy_load_term_meta'] ) {
    37863794            wp_queue_posts_for_term_meta_lazyload( $this->posts );
    37873795        }
Note: See TracChangeset for help on using the changeset viewer.