diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php index 0a74f57b9f..d1cc69d96c 100644 --- a/wp-includes/class-wp-term-query.php +++ b/wp-includes/class-wp-term-query.php @@ -865,7 +865,7 @@ class WP_Term_Query { // Prime termmeta cache. if ( $args['update_term_meta_cache'] ) { $term_ids = wp_list_pluck( $term_objects, 'term_id' ); - update_termmeta_cache( $term_ids ); + wp_lazyload_term_meta( $term_ids ); } if ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) { diff --git a/wp-includes/post.php b/wp-includes/post.php index 7dc67105e1..3c1af397a3 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -7692,10 +7692,7 @@ function wp_queue_posts_for_term_meta_lazyload( $posts ) { } } - if ( $term_ids ) { - $lazyloader = wp_metadata_lazyloader(); - $lazyloader->queue_objects( 'term', $term_ids ); - } + wp_lazyload_term_meta( $term_ids ); } /** diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index e32afbd2c4..925bcb41ee 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1426,6 +1426,22 @@ function update_termmeta_cache( $term_ids ) { return update_meta_cache( 'term', $term_ids ); } + +/** + * Queue term meta for lazy-loading. + * + * @since 6.3.0 + * + * @param array $term_ids List of term IDs. + */ +function wp_lazyload_term_meta( array $term_ids ) { + if ( empty( $term_ids ) ) { + return; + } + $lazyloader = wp_metadata_lazyloader(); + $lazyloader->queue_objects( 'term', $term_ids ); +} + /** * Gets all meta data, including meta IDs, for the given term ID. * @@ -4003,6 +4019,7 @@ function _pad_term_counts( &$terms, $taxonomy ) { * * @since 4.6.0 * @since 6.1.0 This function is no longer marked as "private". + * @since 6.3.0 Use wp_lazyload_term_meta() for lazy-loading of term meta. * * @global wpdb $wpdb WordPress database abstraction object. * @@ -4017,10 +4034,10 @@ function _prime_term_caches( $term_ids, $update_meta_cache = true ) { $fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); update_term_cache( $fresh_terms ); + } - if ( $update_meta_cache ) { - update_termmeta_cache( $non_cached_ids ); - } + if ( $update_meta_cache ) { + wp_lazyload_term_meta( $term_ids ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index c26020a5df..51135f0861 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55670'; +$wp_version = '6.3-alpha-55671'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.