[wp-trac] [WordPress Trac] #59521: Issue with update_post_thumbnail_cache if using get_posts

WordPress Trac noreply at wordpress.org
Mon Oct 14 22:20:25 UTC 2024


#59521: Issue with update_post_thumbnail_cache if using get_posts
----------------------------------------------------+---------------------
 Reporter:  Xendo                                   |       Owner:  antpb
     Type:  defect (bug)                            |      Status:  closed
 Priority:  normal                                  |   Milestone:  6.7
Component:  Media                                   |     Version:  6.3.1
 Severity:  normal                                  |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-testing  |     Focuses:
----------------------------------------------------+---------------------
Changes (by peterwilsoncc):

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


Comment:

 In [changeset:"59235" 59235]:
 {{{
 #!CommitTicketReference repository="" revision="59235"
 Media: Account for post ID queries in `update_post_thumbnail_cache()`.

 Updates `update_post_thumbnail_cache()` to account for `WP_Query` objects
 that only contain the post ID field rather than the entire post object.

 This changes passes the `$post` value to `get_post_thumbnail_id()` rather
 than assuming the presence of the ID property. Additionally, the posts to
 which the thumbnail is attached are now primed prior to calling the
 function to avoid numerous unnecessary database queries.

 The test
 `WP_Test_REST_Posts_Controller::test_get_items_primes_parent_post_caches()`
 is modified to account for an order of operations change for the priming
 of post meta caches. The cache is no longer primed in the final call to
 `update_meta_cache()` so the tests need to account for the post meta to be
 primed in any call to the function.

 Props antpb, jorbin, khokansardar, linsoftware, mukesh27, oglekler,
 rajinsharwar, sumitsingh, xendo.
 Fixes #59521.
 }}}

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


More information about the wp-trac mailing list