Hi.

I'm seeing that the number of topics and posts display as zero.

I disabled the AF module, and the topics and post numbers are displaying correctly. Enabling AF again turns them back to zeros.

Attached is a screenshot for reference.

Thanks, in advance, for any thoughts you might have.

Files: 

Comments

play4quarters’s picture

I was able to get the correct numbers exposed by using the 2.0 recommended release vs. the dev release (testing with the last 2 dev releases without luck.)

troky’s picture

If you want to test, try installing Drupal 7.x-dev and AF 7.x-dev

troky’s picture

Category:bug» support
Status:Active» Fixed

I believe 7.x-dev will work just fine with upcoming Drupal 7.16.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Frank_F2’s picture

Status:Closed (fixed)» Active

Using Drupal 7.19 and AF 7.x-2.0+26-dev, I got zero's for my topic and posts count. Disabling AF does show the correct numbers. Pls help.

end user’s picture

StatusFileSize
new247.3 KB

Just installed AF and having same issue with Drupal 7.23+20-dev and AF 7.x-2.3 and Dev. Treid a defualt theme just to make sure but same results. All statistics and permissions have been checked.

end user’s picture

Hmm so this is not a common issue or are there not enough people using AF to have this problem?

nithyakarthigan’s picture

Issue summary:View changes

Even I have the same problem. anyone find the solution. plz share...

Angrim’s picture

After the update from today , i have the same problem. The number of posts and topics are not counted and displayed.
Anyone have an idea to resolve the problem.

becometa’s picture

same here..

Lemon006’s picture

same here...
With both stable and dev releases (2.4 & 2.x).
Must be related with permissions set from roles because it works on public forums.
Investigating...

-Topic count to zero only when viewing the forum from within it's container. So if i click/show only the container i see it's forums with their correct topics count.

-Turned a private (role based perms) to public and still same bug : Topic count zero on main forum path /drupal/forum/. So it seems not permissions related. Now i will compare the "working containers" with containers with false zero topics count. Finaly topic count was back after few minutes (cron ?), investigating...

Ok i finally did a cron + clear cache and everything is back to normal... i can't explain why, maybe because i installed Dev release then forgot to clear cache + cron.

Angrim’s picture

It must be definitely a role or permission problem.

The forum which has permissions for guest will be displayed correct. Only the forums for the members of the side has the problem.

A cron and clear cache resolve the problem one time.

I use
Drupal 7.33
Forum 7.33
Advanced Forum 7.x-2.4
Advanced Forum More Styles 7.x-2.0-alpha1
Forum Access 7.x-1.2+6-dev

Lemon006’s picture

@#12

Oh just checked and you are right, topics count are back to zero :/
And right, only privates forums are targeted by the bug...

Michelle’s picture

If it's only private forums, could you test to see if the bug occurs with Forum Access enabled and Advanced Forum disabled? That will isolate whether the problem is in Forum Access alone or if there is some conflict between AF and FA.

Angrim’s picture

Hello Michelle,

Only Private Forums are affected.

I have tested it with Advanced Forums deactivated and Forum access activated.
Now will be the number of posts and topics displayed correctly.

Thank you for your help.

Best regards
Angrim

kkalaskar’s picture

StatusFileSize
new24.58 KB
new34.62 KB

Hello to all,

Solution is here
I faced same problem with my forum project. I installed modules -

The 0 count problem occurs because of $count array remains null into the advanced_forum/includes/core-overrides.inc file on line no. 145

<?php
 
if (count($_forums) && empty($counts)) {
   
$query = db_select('node', 'n');
   
$query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
   
$query->join('forum_index', 'f', 'n.nid = f.nid');
   
$query->addExpression('COUNT(DISTINCT(f.nid))', 'topic_count');
   
$query->addExpression('SUM(f.comment_count)', 'comment_count');

   
// Limit the query to only node types that can actually be associated with
    // the forum vocabulary.
   
if ($vid) {
     
$vocabulary = taxonomy_vocabulary_load($vid);
     
$vocabulary_fields = field_read_fields(array('module' => 'taxonomy'));
     
$node_types = array();
      foreach (
$vocabulary_fields as $field_name => $vocabulary_field) {
        foreach (
$vocabulary_field['settings']['allowed_values'] as $key => $allowed_value) {
          if (
$allowed_value['vocabulary'] == $vocabulary->machine_name) {
           
$field_info = field_info_field($field_name);
            if (isset(
$field_info['bundles']['node'])) {
             
$node_types += $field_info['bundles']['node'];
            }
          }
        }
      }

      if (!empty(
$node_types)) {
       
$query->condition('type', $node_types, 'IN');
      }
    }

   
$counts = $query    //This $counts remain null because of $query.
       
->fields('f', array('tid'))
        ->
condition('status', 1)
        ->
groupBy('tid')
        ->
addTag('node_access')
        ->
execute()
        ->
fetchAllAssoc('tid');
   
cache_set('adv_forum_counts' . $tid, $counts, 'cache', time() + 60*60); //1 hour
 
}
?>

This code rendered query like this -
SELECT f.tid AS tid, COUNT(DISTINCT(f.nid)) AS topic_count, SUM(f.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {forum_index} f ON n.nid = f.nid WHERE (type IN (:db_condition_placeholder_0)) AND (status = :db_condition_placeholder_1) AND ( EXISTS (SELECT na.nid AS nid FROM {node_access} na WHERE (( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) )OR( (na.gid = :db_condition_placeholder_6) AND (na.realm = :db_condition_placeholder_7) )OR( (na.gid = :db_condition_placeholder_8) AND (na.realm = :db_condition_placeholder_9) ))AND (na.grant_view >= :db_condition_placeholder_10) AND (n.nid = na.nid) )) GROUP BY tid

So i did small change in it with the reference of Drupal`s core forum module. I changed place of $count.
like -

<?php
if (count($_forums) && empty($counts)) {
   
$query = db_select('node', 'n');
   
$query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid');
   
$query->join('forum_index', 'f', 'n.nid = f.nid');
   
$query->addExpression('COUNT(DISTINCT(f.nid))', 'topic_count');
   
$query->addExpression('SUM(f.comment_count)', 'comment_count');
   
$counts = $query
       
->fields('f', array('tid'))
        ->
condition('status', 1)
        ->
groupBy('tid')
        ->
addTag('node_access')
        ->
execute()
        ->
fetchAllAssoc('tid');

   
// Limit the query to only node types that can actually be associated with
    // the forum vocabulary.
   
if ($vid) {
     
$vocabulary = taxonomy_vocabulary_load($vid);
     
$vocabulary_fields = field_read_fields(array('module' => 'taxonomy'));
     
$node_types = array();
      foreach (
$vocabulary_fields as $field_name => $vocabulary_field) {
        foreach (
$vocabulary_field['settings']['allowed_values'] as $key => $allowed_value) {
          if (
$allowed_value['vocabulary'] == $vocabulary->machine_name) {
           
$field_info = field_info_field($field_name);
            if (isset(
$field_info['bundles']['node'])) {
             
$node_types += $field_info['bundles']['node'];
            }
          }
        }
      }

      if (!empty(
$node_types)) {
       
$query->condition('type', $node_types, 'IN');
      }
    }

   
   
cache_set('adv_forum_counts' . $tid, $counts, 'cache', time() + 60*60); //1 hour
 
}
?>

Now its showing proper count on my forum but I am looking for proper solution.

Dandily’s picture

kkalaskar, thank you a lot, it's work for me!

wla_g’s picture

For me it worked as well. Should be committed.

Michelle’s picture

If someone would turn this into a patch and get it reviewed, that would help a lot. As much as I want to work on AF, I have too much on my plate presently so making it easier for me would make it more likely for me to be able to commit it. :)

PascalAnimateur’s picture

Status:Active» Needs review
StatusFileSize
new1.43 KB
PASSED: [[SimpleTest]]: [MySQL] 72 pass(es).
[ View ]

Here's a patch on 2.x-dev with the modifications from #16 by @kkalaskar

Michelle’s picture

Awesome, thanks! I'll be at DrupalCorn this weekend and am hoping to get in a little contrib time while I'm there. Will have a look.

podarok’s picture

Status:Needs review» Fixed

#20 pushed to dev
Thanks

FrancoisL’s picture

Hello this solved a part of my problems. indeed forum Home Page display now Topic number, Posts and Last post.

I still have a problem when I'm in a forum. I have the topic list but nothing in Replies, Views and last post. I think this is related to "Advanced Forum topic list" Views. When I activate "more Style" Module I see stats in for example "Active topics" but always not in my topic list in all forums.

Is someone can help please?

Thanks in advance.

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.