mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Query: Bypass caching for filtered SELECT
s.
Bypass caching within `WP_Query` when the `SELECT` clause has been modified via a filter. This prevents both cache key collisions and the returning of incomplete or unexpected results when the `SELECT` clause has been modified by an extender. Props pypwalters, claytoncollie, johnwatkins0, TimothyBlynJacobs, costdev, spacedmonkey, peterwilsoncc. Fixes #57012. Built from https://develop.svn.wordpress.org/trunk@54768 git-svn-id: http://core.svn.wordpress.org/trunk@54320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
72cc029989
commit
4c90be7e91
@ -3103,8 +3103,23 @@ class WP_Query {
|
||||
* cannot be cached. Note the space before `RAND` in the string
|
||||
* search, that to ensure against a collision with another
|
||||
* function.
|
||||
*
|
||||
* If `$fields` has been modified by the `posts_fields`,
|
||||
* `posts_fields_request`, `post_clauses` or `posts_clauses_request`
|
||||
* filters, then caching is disabled to prevent caching collisions.
|
||||
*/
|
||||
$id_query_is_cacheable = ! str_contains( strtoupper( $orderby ), ' RAND(' );
|
||||
|
||||
$cachable_field_values = array(
|
||||
"{$wpdb->posts}.*",
|
||||
"{$wpdb->posts}.ID, {$wpdb->posts}.post_parent",
|
||||
"{$wpdb->posts}.ID",
|
||||
);
|
||||
|
||||
if ( ! in_array( $fields, $cachable_field_values, true ) ) {
|
||||
$id_query_is_cacheable = false;
|
||||
}
|
||||
|
||||
if ( $q['cache_results'] && $id_query_is_cacheable ) {
|
||||
$new_request = str_replace( $fields, "{$wpdb->posts}.*", $this->request );
|
||||
$cache_key = $this->generate_cache_key( $q, $new_request );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-alpha-54766';
|
||||
$wp_version = '6.2-alpha-54768';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user