WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#15424 reopened defect (bug)

Refresh post count when a post is deleted

Reported by: chouxpastry2002 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Options, Meta APIs Keywords: has-patch
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 3 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 scribu3 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.

comment:2 nacin3 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' );

comment:3 nacin3 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.

comment:4 scribu3 years ago

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

comment:5 scribu3 years ago

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

comment:6 nacin3 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.

scribu3 years ago

comment:7 scribu3 years ago

  • Keywords has-patch added; reporter-feedback removed

Made a patch anyway.

comment:8 markjaquith3 years ago

  • Milestone changed from 3.1 to Future Release

comment:9 scribu2 years ago

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

comment:10 avryl9 months ago

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

comment:11 follow-up: helen9 months ago

  • Version changed from trunk to 3.1

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

comment:12 avryl9 months ago

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

comment:13 in reply to: ↑ 11 ; follow-up: avryl9 months 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?

comment:14 in reply to: ↑ 13 ; follow-up: DrewAPicture9 months 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.

comment:15 in reply to: ↑ 14 avryl9 months 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!

comment:16 jeremyfelt3 months ago

  • Component changed from Multisite to Options and Meta
  • Focuses multisite added
Note: See TracTickets for help on using tickets.