Skip to content

Commit cb81c62

Browse files
author
boonebgorges
committed
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
1 parent 1813969 commit cb81c62

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

wp-includes/query.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ public function fill_query_vars($array) {
14681468
* @since 4.5.0 Removed the `$comments_popup` parameter.
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
*
14741474
* @param string|array $query {
@@ -1567,6 +1567,10 @@ public function fill_query_vars($array) {
15671567
* @type string $title Post title.
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.
15721576
* }
@@ -2545,6 +2549,10 @@ public function get_posts() {
25452549
if ( !isset($q['update_post_term_cache']) )
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;
25502558

@@ -3782,7 +3790,7 @@ public function get_posts() {
37823790
$this->posts = array();
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
}
37883796

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @global string $wp_version
66
*/
7-
$wp_version = '4.6-alpha-37588';
7+
$wp_version = '4.6-alpha-37589';
88

99
/**
1010
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)