Changeset 53941
- Timestamp:
- 08/25/2022 04:21:40 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-query.php
r53891 r53941 1875 1875 1876 1876 if ( ! isset( $q['cache_results'] ) ) { 1877 if ( wp_using_ext_object_cache() ) { 1878 $q['cache_results'] = false; 1879 } else { 1880 $q['cache_results'] = true; 1881 } 1877 $q['cache_results'] = true; 1882 1878 } 1883 1879 … … 3073 3069 $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); 3074 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3075 3142 if ( 'ids' === $q['fields'] ) { 3076 3143 if ( null === $this->posts ) { … … 3083 3150 $this->set_found_posts( $q, $limits ); 3084 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3085 3162 return $this->posts; 3086 3163 } … … 3095 3172 3096 3173 /** @var int[] */ 3097 $r = array(); 3174 $post_parents = array(); 3175 $post_ids = array(); 3176 3098 3177 foreach ( $this->posts as $key => $post ) { 3099 3178 $this->posts[ $key ]->ID = (int) $post->ID; 3100 3179 $this->posts[ $key ]->post_parent = (int) $post->post_parent; 3101 3180 3102 $r[ (int) $post->ID ] = (int) $post->post_parent; 3103 } 3104 3105 return $r; 3181 $post_parents[ (int) $post->ID ] = (int) $post->post_parent; 3182 $post_ids[] = (int) $post->ID; 3183 } 3184 3185 if ( $q['cache_results'] && $id_query_is_cacheable ) { 3186 $cache_value = array( 3187 'posts' => $post_ids, 3188 'found_posts' => $this->found_posts, 3189 'max_num_pages' => $this->max_num_pages, 3190 ); 3191 3192 wp_cache_set( $cache_key, $cache_value, 'posts' ); 3193 } 3194 3195 return $post_parents; 3106 3196 } 3107 3197 … … 3145 3235 $this->request = apply_filters( 'posts_request_ids', $this->request, $this ); 3146 3236 3147 $ ids = $wpdb->get_col( $this->request );3148 3149 if ( $ ids ) {3150 $this->posts = $ ids;3237 $ids = $wpdb->get_col( $this->request ); 3238 3239 if ( $ids ) { 3240 $this->posts = $ids; 3151 3241 $this->set_found_posts( $q, $limits ); 3152 _prime_post_caches( $ ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );3242 _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); 3153 3243 } else { 3154 3244 $this->posts = array(); … … 3166 3256 } 3167 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3168 3270 if ( ! empty( $this->posts ) && $q['update_menu_item_cache'] ) { 3169 3271 update_menu_item_cache( $this->posts ); … … 3202 3304 $comments_request = "SELECT {$wpdb->comments}.comment_ID FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"; 3203 3305 3204 $ key = md5( $comments_request );3205 $ last_changed = wp_cache_get_last_changed( 'comment' );3206 3207 $c ache_key = "comment_feed:$key:$last_changed";3208 $comment_ids = wp_cache_get( $cache_key, 'comment' );3306 $key = md5( $comments_request ); 3307 $last_changed = wp_cache_get_last_changed( 'comment' ); 3308 3309 $clast_changed"; 3310 $comment_ids cache_key, 'comment' ); 3209 3311 if ( false === $comment_ids ) { 3210 3312 $comment_ids = $wpdb->get_col( $comments_request ); 3211 wp_cache_add( $c ache_key, $comment_ids, 'comment' );3313 wp_cache_add( $cache_key, $comment_ids, 'comment' ); 3212 3314 } 3213 3315 _prime_comment_caches( $comment_ids, false ); -
trunk/tests/phpunit/tests/query/commentFeed.php
r53066 r53941 40 40 'ignore_sticky_posts' => false, 41 41 'no_found_rows' => true, 42 42 43 ); 43 44 $q1->query( $args ); … … 99 100 'update_post_term_cache' => false, 100 101 'ignore_sticky_posts' => false, 102 101 103 ); 102 104
Note: See TracChangeset
for help on using the changeset viewer.