@@ -2884,11 +2884,11 @@ public function get_posts() {
28842884 $ key = md5 ( $ comments_request );
28852885 $ last_changed = wp_cache_get_last_changed ( 'comment ' ) . ': ' . wp_cache_get_last_changed ( 'posts ' );
28862886
2887- $ cache_key = "comment_feed: $ key: $ last_changed " ;
2888- $ comment_ids = wp_cache_get ( $ cache_key , 'comment-queries ' );
2887+ $ cache_key = "comment_feed: $ key " ;
2888+ $ comment_ids = wp_cache_get_query_data ( $ cache_key , 'comment-queries ' , $ last_changed );
28892889 if ( false === $ comment_ids ) {
28902890 $ comment_ids = $ wpdb ->get_col ( $ comments_request );
2891- wp_cache_add ( $ cache_key , $ comment_ids , 'comment-queries ' );
2891+ wp_cache_set_query_data ( $ cache_key , $ comment_ids , 'comment-queries ' , $ last_changed );
28922892 }
28932893 _prime_comment_caches ( $ comment_ids );
28942894
@@ -3246,15 +3246,21 @@ public function get_posts() {
32463246 $ id_query_is_cacheable = false ;
32473247 }
32483248
3249+ $ last_changed = wp_cache_get_last_changed ( 'posts ' );
3250+ if ( ! empty ( $ this ->tax_query ->queries ) ) {
3251+ $ last_changed .= wp_cache_get_last_changed ( 'terms ' );
3252+ }
3253+
32493254 if ( $ q ['cache_results ' ] && $ id_query_is_cacheable ) {
32503255 $ new_request = str_replace ( $ fields , "{$ wpdb ->posts }.* " , $ this ->request );
32513256 $ cache_key = $ this ->generate_cache_key ( $ q , $ new_request );
32523257
32533258 $ cache_found = false ;
32543259 if ( null === $ this ->posts ) {
3255- $ cached_results = wp_cache_get ( $ cache_key , 'post-queries ' , false , $ cache_found );
3260+ $ cached_results = wp_cache_get_query_data ( $ cache_key , 'post-queries ' , $ last_changed );
32563261
32573262 if ( $ cached_results ) {
3263+ $ cache_found = true ;
32583264 /** @var int[] */
32593265 $ post_ids = array_map ( 'intval ' , $ cached_results ['posts ' ] );
32603266
@@ -3312,7 +3318,7 @@ public function get_posts() {
33123318 'max_num_pages ' => $ this ->max_num_pages ,
33133319 );
33143320
3315- wp_cache_set ( $ cache_key , $ cache_value , 'post-queries ' );
3321+ wp_cache_set_query_data ( $ cache_key , $ cache_value , 'post-queries ' , $ last_changed );
33163322 }
33173323
33183324 return $ this ->posts ;
@@ -3486,11 +3492,11 @@ public function get_posts() {
34863492 $ comment_key = md5 ( $ comments_request );
34873493 $ comment_last_changed = wp_cache_get_last_changed ( 'comment ' );
34883494
3489- $ comment_cache_key = "comment_feed: $ comment_key: $ comment_last_changed " ;
3490- $ comment_ids = wp_cache_get ( $ comment_cache_key , 'comment-queries ' );
3495+ $ comment_cache_key = "comment_feed: $ comment_key " ;
3496+ $ comment_ids = wp_cache_get_query_data ( $ comment_cache_key , 'comment-queries ' , $ comment_last_changed );
34913497 if ( false === $ comment_ids ) {
34923498 $ comment_ids = $ wpdb ->get_col ( $ comments_request );
3493- wp_cache_add ( $ comment_cache_key , $ comment_ids , 'comment-queries ' );
3499+ wp_cache_set_query_data ( $ comment_cache_key , $ comment_ids , 'comment-queries ' , $ comment_last_changed );
34943500 }
34953501 _prime_comment_caches ( $ comment_ids );
34963502
@@ -5062,12 +5068,7 @@ static function ( &$value ) use ( $wpdb, $placeholder ) {
50625068 $ sql = $ wpdb ->remove_placeholder_escape ( $ sql );
50635069 $ key = md5 ( serialize ( $ args ) . $ sql );
50645070
5065- $ last_changed = wp_cache_get_last_changed ( 'posts ' );
5066- if ( ! empty ( $ this ->tax_query ->queries ) ) {
5067- $ last_changed .= wp_cache_get_last_changed ( 'terms ' );
5068- }
5069-
5070- $ this ->query_cache_key = "wp_query: $ key: $ last_changed " ;
5071+ $ this ->query_cache_key = "wp_query: $ key " ;
50715072 return $ this ->query_cache_key ;
50725073 }
50735074
0 commit comments