Changeset 60697
- Timestamp:
- 08/31/2025 09:41:54 PM (6 weeks ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cache-compat.php
r54448 r60697 200 200 } 201 201 endif; 202 203 if ( ! function_exists( 'wp_cache_get_salted' ) ) : 204 /** 205 * Retrieves cached data if valid and unchanged. 206 * 207 * @since 6.9.0 208 * 209 * @param string $cache_key The cache key used for storage and retrieval. 210 * @param string $group The cache group used for organizing data. 211 * @param string|string[] $salt The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated. 212 * @return mixed|false The cached data if valid, or false if the cache does not exist or is outdated. 213 */ 214 function wp_cache_get_salted( $cache_key, $group, $salt ) { 215 $salt = is_array( $salt ) ? implode( ':', $salt ) : $salt; 216 $cache = wp_cache_get( $cache_key, $group ); 217 218 if ( ! is_array( $cache ) ) { 219 return false; 220 } 221 222 if ( ! isset( $cache['salt'] ) || ! isset( $cache['data'] ) || $salt !== $cache['salt'] ) { 223 return false; 224 } 225 226 return $cache['data']; 227 } 228 endif; 229 230 if ( ! function_exists( 'wp_cache_set_salted' ) ) : 231 /** 232 * Stores salted data in the cache. 233 * 234 * @since 6.9.0 235 * 236 * @param string $cache_key The cache key under which to store the data. 237 * @param mixed $data The data to be cached. 238 * @param string $group The cache group to which the data belongs. 239 * @param string|string[] $salt The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated. 240 * @param int $expire Optional. When to expire the cache contents, in seconds. 241 * Default 0 (no expiration). 242 * @return bool True on success, false on failure. 243 */ 244 function wp_cache_set_salted( $cache_key, $data, $group, $salt, $expire = 0 ) { 245 $salt = is_array( $salt ) ? implode( ':', $salt ) : $salt; 246 return wp_cache_set( 247 $cache_key, 248 array( 249 'data' => $data, 250 'salt' => $salt, 251 ), 252 $group, 253 $expire 254 ); 255 } 256 endif; 257 258 if ( ! function_exists( 'wp_cache_get_multiple_salted' ) ) : 259 /** 260 * Retrieves multiple items from the cache, only considering valid and unchanged items. 261 * 262 * @since 6.9.0 263 * 264 * @param array $cache_keys Array of cache keys to retrieve. 265 * @param string $group The group of the cache to check. 266 * @param string|string[] $salt The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated. 267 * @return array An associative array containing cache values. Values are `false` if they are not found or outdated. 268 */ 269 function wp_cache_get_multiple_salted( $cache_keys, $group, $salt ) { 270 $salt = is_array( $salt ) ? implode( ':', $salt ) : $salt; 271 $cache = wp_cache_get_multiple( $cache_keys, $group ); 272 273 foreach ( $cache as $key => $value ) { 274 if ( ! is_array( $value ) ) { 275 $cache[ $key ] = false; 276 continue; 277 } 278 if ( ! isset( $value['salt'], $value['data'] ) || $salt !== $value['salt'] ) { 279 $cache[ $key ] = false; 280 continue; 281 } 282 $cache[ $key ] = $value['data']; 283 } 284 285 return $cache; 286 } 287 endif; 288 289 if ( ! function_exists( 'wp_cache_set_multiple_salted' ) ) : 290 /** 291 * Stores multiple pieces of salted data in the cache. 292 * 293 * @since 6.9.0 294 * 295 * @param mixed $data Data to be stored in the cache for all keys. 296 * @param string $group Group to which the cached data belongs. 297 * @param string|string[] $salt The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated. 298 * @param int $expire Optional. When to expire the cache contents, in seconds. 299 * Default 0 (no expiration). 300 * @return bool[] Array of return values, grouped by key. Each value is either 301 * true on success, or false on failure. 302 */ 303 function wp_cache_set_multiple_salted( $data, $group, $salt, $expire = 0 ) { 304 $salt = is_array( $salt ) ? implode( ':', $salt ) : $salt; 305 $new_cache = array(); 306 foreach ( $data as $key => $value ) { 307 $new_cache[ $key ] = array( 308 'data' => $value, 309 'salt' => $salt, 310 ); 311 } 312 return wp_cache_set_multiple( $new_cache, $group, $expire ); 313 } 314 endif; -
trunk/src/wp-includes/class-wp-comment-query.php
r60291 r60697 452 452 $last_changed = wp_cache_get_last_changed( 'comment' ); 453 453 454 $cache_key = "get_comments:$key :$last_changed";455 $cache_value = wp_cache_get ( $cache_key, 'comment-queries');454 $cache_key = "get_comments:$key"; 455 $cache_value = wp_cache_get_salted( $cache_key, 'comment-queries', $last_changed ); 456 456 if ( false === $cache_value ) { 457 457 $comment_ids = $this->get_comment_ids(); … … 464 464 'found_comments' => $this->found_comments, 465 465 ); 466 wp_cache_ add( $cache_key, $cache_value, 'comment-queries');466 wp_cache_set_salted( $cache_key, $cache_value, 'comment-queries', $last_changed ); 467 467 } else { 468 468 $comment_ids = $cache_value['comment_ids']; … … 1045 1045 $cache_keys = array(); 1046 1046 foreach ( $_parent_ids as $parent_id ) { 1047 $cache_keys[ $parent_id ] = "get_comment_child_ids:$parent_id:$key :$last_changed";1048 } 1049 $cache_data = wp_cache_get_multiple ( array_values( $cache_keys ), 'comment-queries');1047 $cache_keys[ $parent_id ] = "get_comment_child_ids:$parent_id:$key"; 1048 } 1049 $cache_data = wp_cache_get_multiple_salted( array_values( $cache_keys ), 'comment-queries', $last_changed ); 1050 1050 foreach ( $_parent_ids as $parent_id ) { 1051 1051 $parent_child_ids = $cache_data[ $cache_keys[ $parent_id ] ]; … … 1081 1081 $data = array(); 1082 1082 foreach ( $parent_map as $parent_id => $children ) { 1083 $cache_key = "get_comment_child_ids:$parent_id:$key :$last_changed";1083 $cache_key = "get_comment_child_ids:$parent_id:$key"; 1084 1084 $data[ $cache_key ] = $children; 1085 1085 } 1086 wp_cache_set_multiple ( $data, 'comment-queries');1086 wp_cache_set_multiple_salted( $data, 'comment-queries', $last_changed ); 1087 1087 } 1088 1088 -
trunk/src/wp-includes/class-wp-network-query.php
r58454 r60697 250 250 $last_changed = wp_cache_get_last_changed( 'networks' ); 251 251 252 $cache_key = "get_network_ids:$key :$last_changed";253 $cache_value = wp_cache_get ( $cache_key, 'network-queries');252 $cache_key = "get_network_ids:$key"; 253 $cache_value = wp_cache_get_salted( $cache_key, 'network-queries', $last_changed ); 254 254 255 255 if ( false === $cache_value ) { … … 263 263 'found_networks' => $this->found_networks, 264 264 ); 265 wp_cache_ add( $cache_key, $cache_value, 'network-queries');265 wp_cache_set_salted( $cache_key, $cache_value, 'network-queries', $last_changed ); 266 266 } else { 267 267 $network_ids = $cache_value['network_ids']; -
trunk/src/wp-includes/class-wp-query.php
r60444 r60697 2883 2883 2884 2884 $key = md5( $comments_request ); 2885 $last_changed = wp_cache_get_last_changed( 'comment' ) . ':' . wp_cache_get_last_changed( 'posts' ); 2886 2887 $cache_key = "comment_feed:$key:$last_changed"; 2888 $comment_ids = wp_cache_get( $cache_key, 'comment-queries' ); 2885 $last_changed = array( 2886 wp_cache_get_last_changed( 'comment' ), 2887 wp_cache_get_last_changed( 'posts' ), 2888 ); 2889 2890 $cache_key = "comment_feed:$key"; 2891 $comment_ids = wp_cache_get_salted( $cache_key, 'comment-queries', $last_changed ); 2889 2892 if ( false === $comment_ids ) { 2890 2893 $comment_ids = $wpdb->get_col( $comments_request ); 2891 wp_cache_ add( $cache_key, $comment_ids, 'comment-queries');2894 wp_cache_set_salted( $cache_key, $comment_ids, 'comment-queries', $last_changed ); 2892 2895 } 2893 2896 _prime_comment_caches( $comment_ids ); … … 3247 3250 } 3248 3251 3252 $last_changed = (array) wp_cache_get_last_changed( 'posts' ); 3253 if ( ! empty( $this->tax_query->queries ) ) { 3254 $last_changed[] = wp_cache_get_last_changed( 'terms' ); 3255 } 3256 3249 3257 if ( $q['cache_results'] && $id_query_is_cacheable ) { 3250 3258 $new_request = str_replace( $fields, "{$wpdb->posts}.*", $this->request ); … … 3253 3261 $cache_found = false; 3254 3262 if ( null === $this->posts ) { 3255 $cached_results = wp_cache_get ( $cache_key, 'post-queries', false, $cache_found );3263 $cached_results = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 3256 3264 3257 3265 if ( $cached_results ) { 3266 $cache_found = true; 3258 3267 /** @var int[] */ 3259 3268 $post_ids = array_map( 'intval', $cached_results['posts'] ); … … 3313 3322 ); 3314 3323 3315 wp_cache_set ( $cache_key, $cache_value, 'post-queries');3324 wp_cache_set_salted( $cache_key, $cache_value, 'post-queries', $last_changed ); 3316 3325 } 3317 3326 … … 3351 3360 ); 3352 3361 3353 wp_cache_set ( $cache_key, $cache_value, 'post-queries');3362 wp_cache_set_salted( $cache_key, $cache_value, 'post-queries', $last_changed ); 3354 3363 } 3355 3364 … … 3449 3458 ); 3450 3459 3451 wp_cache_set ( $cache_key, $cache_value, 'post-queries');3460 wp_cache_set_salted( $cache_key, $cache_value, 'post-queries', $last_changed ); 3452 3461 } 3453 3462 … … 3487 3496 $comment_last_changed = wp_cache_get_last_changed( 'comment' ); 3488 3497 3489 $comment_cache_key = "comment_feed:$comment_key :$comment_last_changed";3490 $comment_ids = wp_cache_get ( $comment_cache_key, 'comment-queries');3498 $comment_cache_key = "comment_feed:$comment_key"; 3499 $comment_ids = wp_cache_get_salted( $comment_cache_key, 'comment-queries', $comment_last_changed ); 3491 3500 if ( false === $comment_ids ) { 3492 3501 $comment_ids = $wpdb->get_col( $comments_request ); 3493 wp_cache_ add( $comment_cache_key, $comment_ids, 'comment-queries');3502 wp_cache_set_salted( $comment_cache_key, $comment_ids, 'comment-queries', $comment_last_changed ); 3494 3503 } 3495 3504 _prime_comment_caches( $comment_ids ); … … 5063 5072 $key = md5( serialize( $args ) . $sql ); 5064 5073 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"; 5074 $this->query_cache_key = "wp_query:$key"; 5071 5075 return $this->query_cache_key; 5072 5076 } -
trunk/src/wp-includes/class-wp-site-query.php
r59009 r60697 358 358 $last_changed = wp_cache_get_last_changed( 'sites' ); 359 359 360 $cache_key = "get_sites:$key :$last_changed";361 $cache_value = wp_cache_get ( $cache_key, 'site-queries');360 $cache_key = "get_sites:$key"; 361 $cache_value = wp_cache_get_salted( $cache_key, 'site-queries', $last_changed ); 362 362 363 363 if ( false === $cache_value ) { … … 371 371 'found_sites' => $this->found_sites, 372 372 ); 373 wp_cache_ add( $cache_key, $cache_value, 'site-queries');373 wp_cache_set_salted( $cache_key, $cache_value, 'site-queries', $last_changed ); 374 374 } else { 375 375 $site_ids = $cache_value['site_ids']; -
trunk/src/wp-includes/class-wp-term-query.php
r60661 r60697 778 778 779 779 if ( $args['cache_results'] ) { 780 $cache_key = $this->generate_cache_key( $args, $this->request ); 781 $cache = wp_cache_get( $cache_key, 'term-queries' ); 780 $cache_key = $this->generate_cache_key( $args, $this->request ); 781 $last_changed = wp_cache_get_last_changed( 'terms' ); 782 $cache = wp_cache_get_salted( $cache_key, 'term-queries', $last_changed ); 782 783 783 784 if ( false !== $cache ) { … … 807 808 $count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 808 809 if ( $args['cache_results'] ) { 809 wp_cache_set ( $cache_key, $count, 'term-queries');810 wp_cache_set_salted( $cache_key, $count, 'term-queries', $last_changed ); 810 811 } 811 812 return $count; … … 816 817 if ( empty( $terms ) ) { 817 818 if ( $args['cache_results'] ) { 818 wp_cache_ add( $cache_key, array(), 'term-queries');819 wp_cache_set_salted( $cache_key, array(), 'term-queries', $last_changed ); 819 820 } 820 821 return array(); … … 901 902 902 903 if ( $args['cache_results'] ) { 903 wp_cache_ add( $cache_key, $term_cache, 'term-queries');904 wp_cache_set_salted( $cache_key, $term_cache, 'term-queries', $last_changed ); 904 905 } 905 906 … … 1173 1174 $sql = $wpdb->remove_placeholder_escape( $sql ); 1174 1175 1175 $key 1176 $last_changed = wp_cache_get_last_changed( 'terms' ); 1177 return "get_terms:$key :$last_changed";1176 $key = md5( serialize( $cache_args ) . $sql ); 1177 1178 return "get_terms:$key"; 1178 1179 } 1179 1180 } -
trunk/src/wp-includes/class-wp-user-query.php
r59542 r60697 831 831 $cache_key = $this->generate_cache_key( $qv, $this->request ); 832 832 $cache_group = 'user-queries'; 833 $last_changed = $this->get_cache_last_changed( $qv ); 834 833 835 if ( $qv['cache_results'] ) { 834 $cache_value = wp_cache_get ( $cache_key, $cache_group);836 $cache_value = wp_cache_get_salted( $cache_key, $cache_group, $last_changed ); 835 837 } 836 838 if ( false !== $cache_value ) { … … 867 869 'total_users' => $this->total_users, 868 870 ); 869 wp_cache_ add( $cache_key, $cache_value, $cache_group);871 wp_cache_set_salted( $cache_key, $cache_value, $cache_group, $last_changed ); 870 872 } 871 873 } … … 1044 1046 * 1045 1047 * @since 6.3.0 1048 * @since 6.9.0 The `$args` parameter was deprecated and renamed to `$deprecated`. 1046 1049 * 1047 1050 * @global wpdb $wpdb WordPress database abstraction object. 1048 1051 * 1049 * @param array $ args Query arguments.1050 * @param string $sql SQL statement.1052 * @param array $deprecated Unused. 1053 * @param string $sql SQL statement. 1051 1054 * @return string Cache key. 1052 1055 */ 1053 protected function generate_cache_key( array $ args, $sql ) {1056 protected function generate_cache_key( array $deprecated, $sql ) { 1054 1057 global $wpdb; 1055 1058 … … 1057 1060 $sql = $wpdb->remove_placeholder_escape( $sql ); 1058 1061 1059 $key = md5( $sql ); 1060 $last_changed = wp_cache_get_last_changed( 'users' ); 1062 $key = md5( $sql ); 1063 1064 return "get_users:$key"; 1065 } 1066 1067 /** 1068 * Retrieves the last changed cache timestamp for users and optionally posts. 1069 * 1070 * @since 6.9.0 1071 * 1072 * @param array $args Query arguments. 1073 * @return string[] The last changed timestamp string for the relevant cache groups. 1074 */ 1075 protected function get_cache_last_changed( array $args ) { 1076 $last_changed = (array) wp_cache_get_last_changed( 'users' ); 1061 1077 1062 1078 if ( empty( $args['orderby'] ) ) { … … 1081 1097 } 1082 1098 1083 $last_changed .= wp_cache_get_last_changed( 'posts' );1099 $last_changed[] = wp_cache_get_last_changed( 'posts' ); 1084 1100 1085 1101 if ( $switch ) { … … 1088 1104 } 1089 1105 1090 return "get_users:$key:$last_changed";1106 return $last_changed; 1091 1107 } 1092 1108 -
trunk/src/wp-includes/general-template.php
r60681 r60697 2070 2070 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; 2071 2071 $key = md5( $query ); 2072 $key = "wp_get_archives:$key :$last_changed";2073 $results = wp_cache_get ( $key, 'post-queries');2072 $key = "wp_get_archives:$key"; 2073 $results = wp_cache_get_salted( $key, 'post-queries', $last_changed ); 2074 2074 if ( ! $results ) { 2075 2075 $results = $wpdb->get_results( $query ); 2076 wp_cache_set ( $key, $results, 'post-queries');2076 wp_cache_set_salted( $key, $results, 'post-queries', $last_changed ); 2077 2077 } 2078 2078 if ( $results ) { … … 2095 2095 $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; 2096 2096 $key = md5( $query ); 2097 $key = "wp_get_archives:$key :$last_changed";2098 $results = wp_cache_get ( $key, 'post-queries');2097 $key = "wp_get_archives:$key"; 2098 $results = wp_cache_get_salted( $key, 'post-queries', $last_changed ); 2099 2099 if ( ! $results ) { 2100 2100 $results = $wpdb->get_results( $query ); 2101 wp_cache_set ( $key, $results, 'post-queries');2101 wp_cache_set_salted( $key, $results, 'post-queries', $last_changed ); 2102 2102 } 2103 2103 if ( $results ) { … … 2119 2119 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; 2120 2120 $key = md5( $query ); 2121 $key = "wp_get_archives:$key :$last_changed";2122 $results = wp_cache_get ( $key, 'post-queries');2121 $key = "wp_get_archives:$key"; 2122 $results = wp_cache_get_salted( $key, 'post-queries', $last_changed ); 2123 2123 if ( ! $results ) { 2124 2124 $results = $wpdb->get_results( $query ); 2125 wp_cache_set ( $key, $results, 'post-queries');2125 wp_cache_set_salted( $key, $results, 'post-queries', $last_changed ); 2126 2126 } 2127 2127 if ( $results ) { … … 2145 2145 $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; 2146 2146 $key = md5( $query ); 2147 $key = "wp_get_archives:$key :$last_changed";2148 $results = wp_cache_get ( $key, 'post-queries');2147 $key = "wp_get_archives:$key"; 2148 $results = wp_cache_get_salted( $key, 'post-queries', $last_changed ); 2149 2149 if ( ! $results ) { 2150 2150 $results = $wpdb->get_results( $query ); 2151 wp_cache_set ( $key, $results, 'post-queries');2151 wp_cache_set_salted( $key, $results, 'post-queries', $last_changed ); 2152 2152 } 2153 2153 $arc_w_last = ''; … … 2184 2184 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; 2185 2185 $key = md5( $query ); 2186 $key = "wp_get_archives:$key :$last_changed";2187 $results = wp_cache_get ( $key, 'post-queries');2186 $key = "wp_get_archives:$key"; 2187 $results = wp_cache_get_salted( $key, 'post-queries', $last_changed ); 2188 2188 if ( ! $results ) { 2189 2189 $results = $wpdb->get_results( $query ); 2190 wp_cache_set ( $key, $results, 'post-queries');2190 wp_cache_set_salted( $key, $results, 'post-queries', $last_changed ); 2191 2191 } 2192 2192 if ( $results ) { -
trunk/src/wp-includes/link-template.php
r60269 r60697 2006 2006 $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; 2007 2007 $key = md5( $query ); 2008 $last_changed = wp_cache_get_last_changed( 'posts' );2008 $last_changed = (array) wp_cache_get_last_changed( 'posts' ); 2009 2009 if ( $in_same_term || ! empty( $excluded_terms ) ) { 2010 $last_changed .= wp_cache_get_last_changed( 'terms' );2011 } 2012 $cache_key = "adjacent_post:$key :$last_changed";2013 2014 $result = wp_cache_get ( $cache_key, 'post-queries');2010 $last_changed[] = wp_cache_get_last_changed( 'terms' ); 2011 } 2012 $cache_key = "adjacent_post:$key"; 2013 2014 $result = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 2015 2015 if ( false !== $result ) { 2016 2016 if ( $result ) { … … 2025 2025 } 2026 2026 2027 wp_cache_set ( $cache_key, $result, 'post-queries');2027 wp_cache_set_salted( $cache_key, $result, 'post-queries', $last_changed ); 2028 2028 2029 2029 if ( $result ) { -
trunk/src/wp-includes/post.php
r60621 r60697 6105 6105 6106 6106 $hash = md5( $page_path . serialize( $post_type ) ); 6107 $cache_key = "get_page_by_path:$hash :$last_changed";6108 $cached = wp_cache_get ( $cache_key, 'post-queries');6107 $cache_key = "get_page_by_path:$hash"; 6108 $cached = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 6109 6109 if ( false !== $cached ) { 6110 6110 // Special case: '0' is a bad `$page_path`. … … 6176 6176 6177 6177 // We cache misses as well as hits. 6178 wp_cache_set ( $cache_key, $found_id, 'post-queries');6178 wp_cache_set_salted( $cache_key, $found_id, 'post-queries', $last_changed ); 6179 6179 6180 6180 if ( $found_id ) { -
trunk/src/wp-includes/query.php
r56434 r60697 1156 1156 $key = md5( $query ); 1157 1157 $last_changed = wp_cache_get_last_changed( 'posts' ); 1158 $cache_key = "find_post_by_old_slug:$key :$last_changed";1159 $cache = wp_cache_get ( $cache_key, 'post-queries');1158 $cache_key = "find_post_by_old_slug:$key"; 1159 $cache = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 1160 1160 if ( false !== $cache ) { 1161 1161 $id = $cache; 1162 1162 } else { 1163 1163 $id = (int) $wpdb->get_var( $query ); 1164 wp_cache_set ( $cache_key, $id, 'post-queries');1164 wp_cache_set_salted( $cache_key, $id, 'post-queries', $last_changed ); 1165 1165 } 1166 1166 … … 1199 1199 $key = md5( $query ); 1200 1200 $last_changed = wp_cache_get_last_changed( 'posts' ); 1201 $cache_key = "find_post_by_old_date:$key :$last_changed";1202 $cache = wp_cache_get ( $cache_key, 'post-queries');1201 $cache_key = "find_post_by_old_date:$key"; 1202 $cache = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 1203 1203 if ( false !== $cache ) { 1204 1204 $id = $cache; … … 1209 1209 $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); 1210 1210 } 1211 wp_cache_set ( $cache_key, $id, 'post-queries');1211 wp_cache_set_salted( $cache_key, $id, 'post-queries', $last_changed ); 1212 1212 } 1213 1213 } -
trunk/src/wp-includes/taxonomy.php
r60676 r60697 897 897 898 898 $last_changed = wp_cache_get_last_changed( 'terms' ); 899 $cache_key = 'get_objects_in_term:' . md5( $sql ) . ":$last_changed";900 $cache = wp_cache_get ( $cache_key, 'term-queries');899 $cache_key = 'get_objects_in_term:' . md5( $sql ); 900 $cache = wp_cache_get_salted( $cache_key, 'term-queries', $last_changed ); 901 901 if ( false === $cache ) { 902 902 $object_ids = $wpdb->get_col( $sql ); 903 wp_cache_set ( $cache_key, $object_ids, 'term-queries');903 wp_cache_set_salted( $cache_key, $object_ids, 'term-queries', $last_changed ); 904 904 } else { 905 905 $object_ids = (array) $cache; -
trunk/src/wp-includes/user.php
r60650 r60697 624 624 625 625 $last_changed = wp_cache_get_last_changed( 'posts' ); 626 $cache_key = 'count_user_posts:' . md5( $query ) . ':' . $last_changed;627 $count = wp_cache_get ( $cache_key, 'post-queries');626 $cache_key = 'count_user_posts:' . md5( $query ); 627 $count = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed ); 628 628 if ( false === $count ) { 629 629 $count = $wpdb->get_var( $query ); 630 wp_cache_set ( $cache_key, $count, 'post-queries');630 wp_cache_set_salted( $cache_key, $count, 'post-queries', $last_changed ); 631 631 } 632 632 -
trunk/tests/phpunit/tests/functions/wpCacheSetLastChanged.php
r57733 r60697 1 1 <?php 2 2 3 /** 3 4 * Tests for the wp_cache_set_last_changed() function. 4 5 * 5 6 * @group functions 7 * @group cache 6 8 * 7 9 * @covers ::wp_cache_set_last_changed
Note: See TracChangeset for help on using the changeset viewer.