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.

Support from Acquia helps fund testing for Drupal Acquia logo

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

FileSize
247.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..

LemonHardos’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

LemonHardos’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

FileSize
24.58 KB
34.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

 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 -


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
FileSize
1.43 KB

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.

luison’s picture

#20 patch works perfectly for me. works but with some changes... see #27

Thanks

luison’s picture

Just one thing.
In my case, I had to delete ->addTag('node_access') lines.
The one from the patch and the other:
$topics = $query
->fields('ncs', array('last_comment_timestamp', 'last_comment_uid'))
->fields('n', array('nid', 'title', 'type'))
->condition('n.status', 1)
->orderBy('last_comment_timestamp', 'DESC')
->range(0, $post_count)
//->addTag('node_access')
->execute();

If not, the forum shows 0 topics and 0 posts even when there are posts and topics.

kalaiselvann’s picture

Luison

I changed above you mentioned #27 and below versions but still showing topics and posts 0.
Drupal 7.43
Advanced Forum 7.x-2.6
Advanced Forum More Styles 7.x-2.0-alpha1
Forum Access 7.x-1.2-dev

kalaiselvann’s picture

I found that the issue is with the feautres module.
Even after uninstalling the feature module the data is still exist in the database. You should delete the database entries manually to solve the issue

grahammiranda13’s picture

OMG #27 luison solved my problem!!!!

THANK YOU SO SO SO MUCH!

grahammiranda13’s picture

do //->addTag('node_access') to all of them on that file!

Anybody’s picture

See follow-up: #2881223: Conditionally bypass node_access when displaying Topic/Post counts and Last Post which replaces #27 with a proper setting. Please review.