Opened 5 years ago
Last modified 8 months ago
#3429 new defect (bug)
bbp_increase_user_topic_count incorrect for first user post
| Reported by: |
|
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)
Change History (4)
#3
@
8 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 try and get that count just-in-time.)
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.