WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 19 months ago

#15424 closed defect (bug) (duplicate)

Refresh post count when a post is deleted

Reported by: chouxpastry2002 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Options, Meta APIs Keywords: has-patch close
Focuses: multisite Cc:

Description

Hi Guys,

I am reporting a bug in the system. I have various users in WPMU. They have their posts and i am tracking their no of posts.

Now if i delete a post from users account post count isnt getting updated. It remains at what it was previously.

eg. If a user has 4 posts in his account and he deleted his one post still the "post_count" field in "wp_options" table remains 4 only. Its not getting updated to 3.

Is there any patch for this ??

Awaiting eagerly for response.

Samir

Attachments (1)

15424.diff (597 bytes) - added by scribu 6 years ago.

Download all attachments as: .zip

Change History (19)

#1 @scribu
6 years ago

  • Keywords reporter-feedback added
  • Severity changed from major to normal

So you're using WP 3.1-alpha?

I think post counts are updated via wp-cron, so it might not happen instantly.

#2 @nacin
6 years ago

Site and user counts are via wp-cron. post_count is handled in the function update_posts_count(), which is indeed attached to the right hook:

./wp-includes/ms-default-filters.php:37:add_action( 'publish_post', 'update_posts_count' );

#3 @nacin
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Let me rephrase, it only gets updated when a post is published. So on post deletion, it will not be updated.

You can attach it to a hook on post deletion if you need that.

#4 @scribu
6 years ago

Wait, why isn't it attached to post deletion too?

#5 @scribu
6 years ago

  • Milestone set to 3.1
  • Resolution wontfix deleted
  • Status changed from closed to reopened

#6 @nacin
6 years ago

I don't know. But it's from MU. I'm not inclined to change it further.

Ideally the post counts should be stored in persistent cache anyway, not the options table.

@scribu
6 years ago

#7 @scribu
6 years ago

  • Keywords has-patch added; reporter-feedback removed

Made a patch anyway.

#8 @markjaquith
6 years ago

  • Milestone changed from 3.1 to Future Release

#9 @scribu
5 years ago

  • Summary changed from A bug in WordPress operation to Refresh post count when a post is deleted

#10 @iseulde
3 years ago

  • Component changed from General to Multisite
  • Version changed from 3.1 to trunk

#11 follow-up: @helen
3 years ago

  • Version changed from trunk to 3.1

Version number indicates when the bug was initially introduced/reported.

#12 @iseulde
3 years ago

Sorry, changed by accident. Just noticed, but you were faster!

#13 in reply to: ↑ 11 ; follow-up: @iseulde
3 years ago

Replying to helen:

Version number indicates when the bug was initially introduced/reported.

I know this is the wrong place to mention this, but sometimes when I load a ticket it sets the version to trunk instead of the actual version. Is this a know issue?

#14 in reply to: ↑ 13 ; follow-up: @DrewAPicture
3 years ago

Replying to avryl:

Replying to helen:

Version number indicates when the bug was initially introduced/reported.

I know this is the wrong place to mention this, but sometimes when I load a ticket it sets the version to trunk instead of the actual version. Is this a know issue?

Maybe make a ticket on Meta Trac if it's a recurring problem.

#15 in reply to: ↑ 14 @iseulde
3 years ago

Replying to DrewAPicture:

Replying to avryl:

Replying to helen:

Version number indicates when the bug was initially introduced/reported.

I know this is the wrong place to mention this, but sometimes when I load a ticket it sets the version to trunk instead of the actual version. Is this a know issue?

Maybe make a ticket on Meta Trac if it's a recurring problem.

Thanks!

#16 @jeremyfelt
3 years ago

  • Component changed from Multisite to Options and Meta
  • Focuses multisite added

#17 @MikeHansenMe
19 months ago

  • Keywords close added

Looks like this was fixed in #27952

#18 @helen
19 months ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #27952.

Note: See TracTickets for help on using tickets.