[wp-trac] [WordPress Trac] #27952: get_blog_details()->post_count Does not subtract deleted posts

WordPress Trac noreply at wordpress.org
Sun Jun 8 18:44:39 UTC 2014


#27952: get_blog_details()->post_count Does not subtract deleted posts
--------------------------------------+------------------------
 Reporter:  GSMcNamara                |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  4.0
Component:  Networks and Sites        |     Version:  3.8.1
 Severity:  minor                     |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:  multisite
--------------------------------------+------------------------

Comment (by strangerstudios):

 I just ran a test on 3.9.1 and when you force delete a post (and thus skip
 the trash status) the `transition_post_status` hook is NOT fired. I don't
 believe there is a way to delete without trashing first in the vanilla
 admin, but you can with a function call like this:

 `wp_delete_post( 2855, true);  //setting $force_delete to true`

 So we will still want to hook into post_delete to catch these cases I'd
 think.

 Also, the count will only be changing if the status is changing to or from
 "publish" (or being force deleted). The `transition_post_status` hook
 passes `$new_status`, `$old_status`, and `$post` as params. If we did a
 test `if($new_status == "publish" || $old_status == "publish")`, we could
 avoid resetting the count (and what could be a decently long query on very
 large sites) if the status was changing from draft to trash or something
 like this.

 If this makes sense, I can write a new patch that keeps the post_delete
 hook in there and possibly updated the function to optionally take
 `$new_status` and `$old_status` params to test them before updating the
 count.

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


More information about the wp-trac mailing list