Bug #863

Rebuilding Forum Counters, doesn't count unapproved threads properly

Added by zinga burga about 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:04/09/2010
Priority:NormalDue date:
Assignee:Ryan Gordon% Done:

100%

Category:Counters
Target version:1.6.0 Beta
Reproducibility:Often Database Type:
Reported In MyBB Version:1.4.11 Database Version:
PHP Version: SQA assignments:
Browser:

Description

The rebuild_forum_counters() in inc/functions_rebuild.php is primarily responsible for rebuilding forum counters, so we'll examine this.
For unapproved threads, it just sums the number of approved and unapproved replies but doesn't count the first post in the thread.
Example:
  1. Log in as admin/moderator
  2. Make new thread in a forum (for simplicity's sake, we'll do it in an empty forum)
  3. Unapprove this thread
  4. If the forum was initially empty, the forum counters should now be: Threads: 0 (1), Posts: 0 (1)
  5. Run a recount forum counters in the AdminCP
  6. The unapproved post in the count is now gone

Fix should be simple - just add in 1 for the implied unapproved first post in the recount.

History

#1 Updated by Ryan Gordon almost 4 years ago

I think this fix works:

$count['unapprovedposts'] = $count2['impliedunapproved'];

to

$count['unapprovedposts'] = $count2['impliedunapproved']+$count2['threads'];

#2 Updated by Ryan Gordon almost 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Ryan Gordon
  • Target version set to 1.6.0 Beta

#3 Updated by Ryan Gordon almost 4 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4918.

#4 Updated by Huji Lee almost 4 years ago

  • Status changed from Resolved to Feedback

I think there's something wrong here. You're adding $count2['threads'], while you need to add a number of "posts" not "threads". Make sure you don't get correct results just because the change in the number of posts and threads is equal.

PS: I didn't test, I'm just talking based on the code. If I'm wrong, please excuse me.

#5 Updated by Ryan Gordon almost 4 years ago

  • Status changed from Feedback to Resolved

Huji...

number of replies plus # of threads = # total number of posts in the given threads

#6 Updated by Michael Malin almost 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF