How to fix incorrect forum post count when using internalization and locale? Using (among several other contrib modules)


Forum 
Locale 
Advanced Forum 
Internationalization


My forum topic nodes are set to be localized and I've set translations for the Forum Vocabulary and all the terms. The forums work well with Internationalization after I modified some of the views and added a 'Content: Language (= Current user's language)' filter.

However the Topics count in the main forum page is incorrect, it doesn't take into account the language, so we  see a higher count than we should.

For example:
https://freshwaterwatch.thewaterhub.org/forum

The 'Meet &amp; Greet' forum has five topics but when you enter you only see two topics: https://freshwaterwatch.thewaterhub.org/forums/meet-and-greet

What happens is that if you click on the French language you see one and two more in the Spanish language, that's why the count for the forum is 5 but you should instead see a count of 2 when browsing the site in the default english language.

Does anyone know how to solve this or a workaround?
Look at advanced_forum_statistics_topics (check your advanced_forum version)

return db_result(db_query('SELECT COUNT(DISTINCT(nid)) FROM {forum}'));


You can use preprocess forum_statistics and instead of advanced_forum_statistics_topics(); use your own function to select only nids which relate to the current language.