Skip to:
Content

bbPress.org

Opened 5 years ago

Closed 6 days ago

Last modified 6 days ago

#3429 closed defect (bug) (fixed)

bbp_increase_user_topic_count incorrect for first user post

Reported by: Robin W Owned by: johnjamesjacoby
Priority: normal Milestone: 2.7
Component: Component - Topics Version:
Severity: normal Keywords: has-patch 2nd-opinion
Cc: naxoc

Description

bbp_increase_user_topic_count and bbp_increase_user_reply_count both incorrectly calculate the count for a first post by an author making it 2 not 1.

This is because the function looks at the user reply count, and if empty (as it will be for a first post) uses bbp_get_user_topic_count_raw to count the topics or bbp_get_user_reply_count_raw to count the replies.

It then increments this count by 1.

However since the topic or reply for that author has already been created by the time this bbp_get_user_topic_count_raw count happens, then it is counted here and then incremeted by 1 which makes it 2.

Attachments (1)

3429.patch (1.4 KB ) - added by naxoc 4 years ago.

Download all attachments as: .zip

Change History (6)

@naxoc
4 years ago

#1 @naxoc
4 years ago

  • Cc naxoc added

I tried for a stab at some code to solve this. It might be better to solve this earlier in the execution, but since the raw call has the truth I figured it could work.

It relies on a long comment to explain what is going on, which is not ideal but it's a start.

#2 @naxoc
4 years ago

  • Component GeneralComponent - Topics
  • Keywords has-patch added

#3 @johnjamesjacoby
15 months ago

  • Keywords 2nd-opinion added
  • Milestone Awaiting Review2.7

I'm able to replicate this. Thanks @robin-w!

The patch from @naxoc does prevent the bug from happening, but I can imagine it not working when untrashing or unspamming if (for some reason) the count meta is missing.

I think, this will need a bit more thinking. 🧐

(It seems like a bad idea to try and get that count just-in-time.)

Version 1, edited 15 months ago by johnjamesjacoby (previous) (next) (diff)

#4 @johnjamesjacoby
6 days ago

  • Owner set to johnjamesjacoby
  • Resolutionfixed
  • Status newclosed

In 7449:

Counts: synchronize counts on post-status transitions.

Replace the mixed moderation callbacks with one persisted-status transition callback for topic, reply, forum, and user counts. Handle new public and hidden content, avoid changes for hidden-to-hidden transitions, preserve reply totals during approval, and repair missing user counts without double-counting the first contribution.

Remove the obsolete child-cache invalidation workaround, prevent topic metadata from being recreated after permanent deletion, recount hidden forum replies during deletion, preserve forum visibility when restoring forums, and order contribution queries for the WordPress post-count index.

In trunk, for 2.7.

Props netweb.
Fixes #2944.
Fixes #3429.
Fixes #3645.
See #1859, #2233, #3433.

#5 @johnjamesjacoby
6 days ago

In 7451:

Counts: synchronize counts on post-status transitions.

Replace the mixed moderation callbacks with one persisted-status transition callback for topic, reply, forum, and user counts. Handle new public and hidden content, avoid changes for hidden-to-hidden transitions, preserve reply totals during approval, and repair missing user counts without double-counting the first contribution.

Remove the obsolete child-cache invalidation workaround, prevent topic metadata from being recreated after permanent deletion, recount hidden forum replies during deletion, preserve forum visibility when restoring forums, and order contribution queries for the WordPress post-count index.

Merges r7449 to 2.6.

In 2.6, for 2.6.16.

See #1859, #2233, #2944, #3429, #3433, #3645.

Note: See TracTickets for help on using tickets.