Query: Remove placeholder from query cache key.
Remove escape placeholder from query cache key, as placeholders are a based on a unique id on every request. This means that it is impossible for a cache to be reused, making queries that use escape placeholders such as `LIKE` searches, unable to be cached. Props dhl, spacedmonkey, peterwilsoncc, desrosj, chaion07, davidbaumwald, mukesh27. Fixes #56802. Built from https://develop.svn.wordpress.org/trunk@54634 git-svn-id: http://core.svn.wordpress.org/trunk@54186 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6743ca5fc4
commit
ac1c0a7171
|
@ -3115,10 +3115,12 @@ class WP_Query {
|
|||
$cache_args['update_post_meta_cache'],
|
||||
$cache_args['update_post_term_cache'],
|
||||
$cache_args['lazy_load_term_meta'],
|
||||
$cache_args['update_menu_item_cache']
|
||||
$cache_args['update_menu_item_cache'],
|
||||
$cache_args['search_orderby_title']
|
||||
);
|
||||
|
||||
$new_request = str_replace( $fields, "{$wpdb->posts}.*", $this->request );
|
||||
$new_request = $wpdb->remove_placeholder_escape( $new_request );
|
||||
$key = md5( serialize( $cache_args ) . $new_request );
|
||||
|
||||
$last_changed = wp_cache_get_last_changed( 'posts' );
|
||||
|
@ -3127,6 +3129,19 @@ class WP_Query {
|
|||
}
|
||||
|
||||
$cache_key = "wp_query:$key:$last_changed";
|
||||
|
||||
/**
|
||||
* Filters query cache key.
|
||||
*
|
||||
* @since 6.1.0
|
||||
*
|
||||
* @param string $cache_key Cache key.
|
||||
* @param array $cache_args Query args used to generate the cache key.
|
||||
* @param string $new_request SQL Query.
|
||||
* @param WP_Query $query The WP_Query instance.
|
||||
*/
|
||||
$cache_key = apply_filters( 'wp_query_cache_key', $cache_key, $cache_args, $new_request, $this );
|
||||
|
||||
$cache_found = false;
|
||||
if ( null === $this->posts ) {
|
||||
$cached_results = wp_cache_get( $cache_key, 'posts', false, $cache_found );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-RC1-54633';
|
||||
$wp_version = '6.1-RC1-54634';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue