Conditions for bug replication

  • Checked Get the number of new comments per forum on the forum list from admin/config/content/advanced-forum ( If checked, Advanced Forum will get the number of new comments as well and show it under "posts" on the forum overview. Slow query not recommended on large forums.)
  • Create new revision enabled ( site level from admin/structure/types/manage/forum or by each post)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Drupa1ish’s picture

FileSize
1.27 KB
troky’s picture

Status: Active » Needs review
FileSize
609 bytes

Try this simple patch.

Drupa1ish’s picture

#2 works. Nice!

daften’s picture

Just reporting I also have this problem. Will try patch from #2

daften’s picture

Title: Wrong number of new posts (comments+topics) with revision enabled » Wrong number of (new) posts (comments+topics) with revision enabled

I also have the wrong number for number of topics and replies in the forum listings and for the statistics with number of replies at the bottom of the forum listing.
Changing current lines 145 through 147 from

$query->join('forum_index', 'f', 'n.nid = f.nid');
$query->addExpression('COUNT(f.nid)', 'topic_count');
$query->addExpression('SUM(f.comment_count)', 'comment_count');

back to the 7.x-2.0 code:

$query->join('forum', 'f', 'n.vid = f.vid');
$query->addExpression('COUNT(n.nid)', 'topic_count');
$query->addExpression('SUM(ncs.comment_count)', 'comment_count');

Fixed the counts in the forum lists

Looking for the other issue now

troky’s picture

@daften:
Can you show me example of wrong topic count?
Above patch (#5) was applied as per #145353: Forums performance improvements

Drupa1ish’s picture

Title: Wrong number of (new) posts (comments+topics) with revision enabled » Wrong number of new posts (comments+topics) with revision enabled
Status: Needs review » Closed (fixed)

@daften. This issue is only for new posts and topics.
#2 fixed this. So i suggest to close it.

We have opened a new issue for general wrong topics count #1948652: Wrong topics and posts count

daften’s picture

Status: Closed (fixed) » Active

Yes, but the problem there is a different problem due to forum hierarchy
As far as comment #7 is concerned, yes, for the forum module. This code is in the advanced_forum module in the function that was copied from forum.module...

The main problem is the double entries in the forum_index table, I don't understand at all why they would be necessary. They are exact duplicates ... I've asked for more info on issue #1466458: Duplicate entries in in forum_index table

troky’s picture

@daften:

does changing line (from #5):

$query->addExpression('COUNT(f.nid)', 'topic_count');

to:

$query->addExpression('COUNT(DISTINCT(f.nid))', 'topic_count');

solve the problem? (using forum_index table, of course).

troky’s picture

Status: Active » Closed (fixed)

Closing this.

dysrama’s picture

Version: 7.x-2.x-dev » 7.x-2.1
FileSize
684 bytes

@troky. putting the distinct on the count for forum_index fixes the wrong topic count yes.

For people who just need this to work right now, I made a patch that applies to the 7.x-2.1 version of advanced forum, since the core issue doesn't seem to be advancing at all.