Skip to:
Content

bbPress.org

Opened 4 years ago

Last modified 4 months ago

#3429 new defect (bug)

bbp_increase_user_topic_count incorrect for first user post

Reported by: robin-w's profile Robin W Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: Component - Topics 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 3 years ago.

Download all attachments as: .zip

Change History (4)

@naxoc
3 years ago

#1 @naxoc
3 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
3 years ago

  • Component changed from General to Component - Topics
  • Keywords has-patch added

#3 @johnjamesjacoby
4 months ago

  • Keywords 2nd-opinion added
  • Milestone changed from Awaiting Review to 2.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 get that raw count just-in-time ever.)

Last edited 4 months ago by johnjamesjacoby (previous) (diff)
Note: See TracTickets for help on using tickets.