[wp-trac] [WordPress Trac] #57023: _update_posts_count_on_delete() is still called incorrectly

WordPress Trac noreply at wordpress.org
Fri Feb 24 01:22:09 UTC 2023


#57023: _update_posts_count_on_delete() is still called incorrectly
-------------------------------+-----------------------------
 Reporter:  SergeyBiryukov     |       Owner:  SergeyBiryukov
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:  6.2
Component:  Posts, Post Types  |     Version:  5.9
 Severity:  normal             |  Resolution:  fixed
 Keywords:  has-patch          |     Focuses:  multisite
-------------------------------+-----------------------------
Changes (by SergeyBiryukov):

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


Comment:

 In [changeset:"55419" 55419]:
 {{{
 #!CommitTicketReference repository="" revision="55419"
 Posts, Post Types: Pass the post object to
 `_update_posts_count_on_delete()`.

 The function checks the status of the post being deleted, and then only
 calls `update_posts_count()` if the deleted post was previously published,
 as the update query would be unnecessary otherwise.

 However, by the time the function runs, the post is already deleted from
 the database, and the post status check fails.

 This commit uses the previously retrieved post object for the status
 check, so that the function proceeds as expected.

 Includes updating the unit test to call `wp_delete_post()` with the
 `$force_delete` argument, so that the post is actually deleted, not
 trashed, and the `after_delete_post` action is run.

 Follow-up to [28835], [52207], [54760], [54762].

 Fixes #57023.
 }}}

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


More information about the wp-trac mailing list