Changeset 56763 for trunk/src/wp-includes/class-wp-query.php
- Timestamp:
- 10/03/2023 02:59:22 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r56656 r56763 3180 3180 3181 3181 if ( $cached_results ) { 3182 if ( 'ids' === $q['fields'] ) { 3183 /** @var int[] */ 3184 $this->posts = array_map( 'intval', $cached_results['posts'] ); 3185 } else { 3186 _prime_post_caches( $cached_results['posts'], $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 3187 /** @var WP_Post[] */ 3188 $this->posts = array_map( 'get_post', $cached_results['posts'] ); 3189 } 3190 3191 $this->post_count = count( $this->posts ); 3182 /** @var int[] */ 3183 $post_ids = array_map( 'intval', $cached_results['posts'] ); 3184 3185 $this->post_count = count( $post_ids ); 3192 3186 $this->found_posts = $cached_results['found_posts']; 3193 3187 $this->max_num_pages = $cached_results['max_num_pages']; 3194 3188 3195 3189 if ( 'ids' === $q['fields'] ) { 3190 $this->posts = $post_ids; 3191 3196 3192 return $this->posts; 3197 3193 } elseif ( 'id=>parent' === $q['fields'] ) { 3194 _prime_post_parents_caches( $post_ids ); 3195 3198 3196 /** @var int[] */ 3199 $post_parents = array();3200 3201 foreach ( $ this->posts as $key => $post ) {3197 $post_parents = wp_cache_get_multiple( $post_ids, 'post_parent' ); 3198 3199 foreach ( $post_parents as $id => $post_parent ) { 3202 3200 $obj = new stdClass(); 3203 $obj->ID = (int) $post->ID; 3204 $obj->post_parent = (int) $post->post_parent; 3205 3206 $this->posts[ $key ] = $obj; 3207 3208 $post_parents[ $obj->ID ] = $obj->post_parent; 3201 $obj->ID = (int) $id; 3202 $obj->post_parent = (int) $post_parent; 3203 3204 $this->posts[] = $obj; 3209 3205 } 3210 3206 3211 3207 return $post_parents; 3208 } else { 3209 _prime_post_caches( $post_ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 3210 /** @var WP_Post[] */ 3211 $this->posts = array_map( 'get_post', $post_ids ); 3212 3212 } 3213 3213 } … … 3257 3257 $post_ids[] = (int) $post->ID; 3258 3258 } 3259 // Prime post parent caches, so that on second run, there is not another database query. 3260 wp_cache_add_multiple( $post_parents, 'post_parent' ); 3259 3261 3260 3262 if ( $q['cache_results'] && $id_query_is_cacheable ) {
Note: See TracChangeset
for help on using the changeset viewer.