[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
Thu Sep 21 19:33:11 UTC 2023


#58599: WP_Query->get_posts: cache updated also when query is set to be not
cacheable
--------------------------------------+---------------------------
 Reporter:  saulirajala               |       Owner:  spacedmonkey
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  6.4
Component:  Query                     |     Version:  6.2
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+---------------------------
Changes (by spacedmonkey):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56656" 56656]:
 {{{
 #!CommitTicketReference repository="" revision="56656"
 Query: Improved handling of filtered queries in WP_Query.

 The `WP_Query` class enables developers to customize queries using filters
 like `posts_fields_request`, `posts_request`, and `the_posts`, which can
 modify both the queried fields and retrieved post objects. In some cases
 with these filters, incomplete or invalid post objects lacking essential
 data may arise. To address this, if any of these filters are active during
 a query, the `get_posts` method now avoids caching post objects with the
 usual `update_post_caches` function call, opting for a call to
 `_prime_post_caches` instead. This may occasionally trigger new database
 queries to prime the post data cache. While this enhancement may result in
 rare additional database queries, it ensures that invalid post objects
 aren't cached, prioritizing data consistency and integrity in filtered
 query scenarios.

 Props saulirajala, spacedmonkey, flixos90, mukesh27, peterwilsoncc.
 Fixes #58599.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58599#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list