From 7a9ed544e8eaa35f2b436639e56e79d92cf6d63e Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 28 May 2016 03:10:29 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@37589 git-svn-id: http://core.svn.wordpress.org/trunk@37557 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 12 ++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index b0df07b0ee..d6915de507 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1468,7 +1468,7 @@ class WP_Query { * @since 4.5.0 Removed the `$comments_popup` parameter. * Introduced the `$comment_status` and `$ping_status` parameters. * Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts. - * @since 4.6.0 Added 'post_name__in' support for `$orderby`. + * @since 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced `$lazy_load_term_meta`. * @access public * * @param string|array $query { @@ -1567,6 +1567,10 @@ class WP_Query { * @type string $title Post title. * @type bool $update_post_meta_cache Whether to update the post meta cache. Default true. * @type bool $update_post_term_cache Whether to update the post term cache. Default true. + * @type bool $lazy_load_term_meta Whether to lazy-load term meta. Setting to false will + * disable cache priming for term meta, so that each + * get_term_meta() call will hit the database. + * Defaults to the value of `$update_post_term_cache`. * @type int $w The week number of the year. Default empty. Accepts numbers 0-53. * @type int $year The four-digit year. Default empty. Accepts any four-digit year. * } @@ -2545,6 +2549,10 @@ class WP_Query { if ( !isset($q['update_post_term_cache']) ) $q['update_post_term_cache'] = true; + if ( ! isset( $q['lazy_load_term_meta'] ) ) { + $q['lazy_load_term_meta'] = $q['update_post_term_cache']; + } + if ( !isset($q['update_post_meta_cache']) ) $q['update_post_meta_cache'] = true; @@ -3782,7 +3790,7 @@ class WP_Query { $this->posts = array(); } - if ( $q['update_post_term_cache'] ) { + if ( $q['lazy_load_term_meta'] ) { wp_queue_posts_for_term_meta_lazyload( $this->posts ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 147167953c..ba5ec9497f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37588'; +$wp_version = '4.6-alpha-37589'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.