[wp-trac] [WordPress Trac] #58599: WP_Query->get_posts: cache updated also when query is set to be not cacheable
WordPress Trac
noreply at wordpress.org
Mon Jul 24 11:20:57 UTC 2023
#58599: WP_Query->get_posts: cache updated also when query is set to be not
cacheable
--------------------------+------------------------------
Reporter: saulirajala | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 6.2
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
--------------------------+------------------------------
Comment (by saulirajala):
Replying to [comment:4 peterwilsoncc]:
> To ensure the cache contains all the expected data when the fields are
modified, I think the code would need to be something like this:
>
> {{{#!php
> <?php
> if ( $q['cache_results'] ) {
> if ( $id_query_is_cacheable ) {
> update_post_caches( $this->posts, $post_type,
$q['update_post_term_cache'], $q['update_post_meta_cache'] );
> } else {
> $post_ids = wp_list_pluck( $this->posts, 'ID' );
> _prime_post_caches( $post_ids,
$q['update_post_term_cache'], $q['update_post_meta_cache'] );
> }
> }
>
> }}}
Hmm, you are probably right. That change would at least preserve the old
behaviour (before r33035) for non-cacheable queries.
I still find it weird, that the query we explicitly set as non-cacheable,
is cached after all. It seems to be an contradictory behaviour potentially
leading to more nasty cache issues.
But what do you say @spacedmonkey: Should I update the patch according to
the suggestion by @peterwilsoncc?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58599#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list