[wp-trac] [WordPress Trac] #57012: WP_Query caching discards `posts_fields` and `posts_clauses['fields']` filters.

WordPress Trac noreply at wordpress.org
Fri Nov 11 23:25:03 UTC 2022


#57012: WP_Query caching discards `posts_fields` and `posts_clauses['fields']`
filters.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
                                                 |  peterwilsoncc
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.1.1
Component:  Query                                |     Version:  6.1
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests commit      |     Focuses:
  fixed-major                                    |  performance
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 Thanks @SergeyBiryukov, the patch looks good based on a visual review.

 As an educated guess, this is caused by hitting undefined behavior due to
 `create_many` creating several posts with the same date/time fields.

 WP_Query is generating the DB Query below and each engine refines the
 order further using a different index.

 {{{#!sql
 SELECT SQL_CALC_FOUND_ROWS  wptests_posts.ID, wptests_posts.post_parent
 FROM wptests_posts
 WHERE 1=1
         AND ((wptests_posts.post_type = 'wptests_pt'
         AND (wptests_posts.post_status = 'publish')))
 ORDER BY wptests_posts.post_date DESC
 LIMIT 0, 10
 }}}

 See also #42936, #56991.

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


More information about the wp-trac mailing list