Changeset 55252
- Timestamp:
- 02/07/2023 12:07:46 PM (20 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r55248 r55252 1949 1949 if ( ! isset( $q['lazy_load_term_meta'] ) ) { 1950 1950 $q['lazy_load_term_meta'] = $q['update_post_term_cache']; 1951 } elseif ( $q['lazy_load_term_meta'] ) { // Lazy loading term meta only works if term caches are primed. 1952 $q['update_post_term_cache'] = true; 1951 1953 } 1952 1954 -
trunk/src/wp-includes/post.php
r55217 r55252 7780 7780 function wp_queue_posts_for_term_meta_lazyload( $posts ) { 7781 7781 $post_type_taxonomies = array(); 7782 $ term_ids= array();7782 $prime_post_terms = array(); 7783 7783 foreach ( $posts as $post ) { 7784 7784 if ( ! ( $post instanceof WP_Post ) ) { … … 7791 7791 7792 7792 foreach ( $post_type_taxonomies[ $post->post_type ] as $taxonomy ) { 7793 // Term cache should already be primed by `update_post_term_cache()`. 7794 $terms = get_object_term_cache( $post->ID, $taxonomy ); 7795 if ( false !== $terms ) { 7796 foreach ( $terms as $term ) { 7797 if ( ! in_array( $term->term_id, $term_ids, true ) ) { 7798 $term_ids[] = $term->term_id; 7793 $prime_post_terms[ $taxonomy ][] = $post->ID; 7794 } 7795 } 7796 7797 $term_ids = array(); 7798 if ( $prime_post_terms ) { 7799 $prime_term_ids = array(); 7800 $prime_taxonomy_ids = array(); 7801 foreach ( $prime_post_terms as $taxonomy => $post_ids ) { 7802 $cached_term_ids = wp_cache_get_multiple( $post_ids, "{$taxonomy}_relationships" ); 7803 if ( is_array( $cached_term_ids ) ) { 7804 $cached_term_ids = array_filter( $cached_term_ids ); 7805 foreach ( $cached_term_ids as $term_ids ) { 7806 // Backward compatibility for if a plugin is putting objects into the cache, rather than IDs. 7807 foreach ( $term_ids as $term_id ) { 7808 if ( is_numeric( $term_id ) ) { 7809 $prime_term_ids[] = (int) $term_id; 7810 $prime_taxonomy_ids[ $taxonomy ][] = (int) $term_id; 7811 } elseif ( isset( $term_id->term_id ) ) { 7812 $prime_taxonomy_ids[ $taxonomy ][] = (int) $term_id->term_id; 7813 $prime_term_ids[] = (int) $term_id->term_id; 7814 } 7799 7815 } 7816 } 7817 } 7818 } 7819 7820 if ( $prime_term_ids ) { 7821 $prime_term_ids = array_unique( $prime_term_ids ); 7822 // Do not prime term meta at this point, let the lazy loader take care of that. 7823 _prime_term_caches( $prime_term_ids, false ); 7824 7825 foreach ( $prime_taxonomy_ids as $taxonomy => $_term_ids ) { 7826 foreach ( $_term_ids as $term_id ) { 7827 if ( in_array( $term_id, $term_ids, true ) ) { 7828 continue; 7829 } 7830 $term = get_term( $term_id, $taxonomy ); 7831 if ( is_wp_error( $term ) ) { 7832 continue; 7833 } 7834 7835 $term_ids[] = $term_id; 7800 7836 } 7801 7837 } -
trunk/tests/phpunit/includes/abstract-testcase.php
r55160 r55252 195 195 $this->_restore_hooks(); 196 196 wp_set_current_user( 0 ); 197 198 $lazyloader = wp_metadata_lazyloader(); 199 $lazyloader->reset_queue( 'term' ); 200 $lazyloader->reset_queue( 'comment' ); 197 201 } 198 202
Note: See TracChangeset
for help on using the changeset viewer.