Active
Project:
Term Node Count
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Anonymous (not verified)
Created:
24 Jul 2010 at 11:23 UTC
Updated:
8 Sep 2017 at 10:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commented1. Changes in term_node_count.install
Schema
a. The schema no includes columns for "gid" (domain_id) and "language" (node language via locale module)
b. The primary key now contains 3 items:
'primary key' => array('tid', 'gid', 'language')First install: pre-filling the count table
a. adapted the query to cycle through domains & integrate with language
This code correctly filles the table with counts per domain/language combination, e.g. 0-en, 0-fr, 2-en, 2-de etc., for each term tid.
Comment #2
Anonymous (not verified) commented2. Changes in term_node_count.module
a. The function
term_node_count_updateneeds two extra arguments, $node->language and $node->domains, which are already available in _nodeapi hook.So change to all function calls to
term_node_count_update($tids_to_update, $node->language, $node->domains);b. That function then cycles through each given $node->domains as $gid (domain_id) and $node->language.
We use a query of the type INSERT INTO ... ON DUPLICATE KEY UPDATE .... Thanks to the primary key triplet (gid, language, tid), we can safely update the counts correctly. Using only 1 query.
c. The function mt_node_count_count_nodes also needs two extra arguments, the only change we make is the query.The new query counts by language & given domain.
What is powerful about above changes, it works from any source domain, and any source language: the counts are always updated correctly.
Comment #3
Anonymous (not verified) commented3. Changes in term_node_count.views.inc
a. We want to filter our views by domain counts, so we simply add this (depends on domain.module):
-------------
Felt like writing up my changes, for others to learn from, and perhaps all of this can be an optional admin.setting for the term_node_count module.
Comment #4
jp.stacey commentedHi morningtime,
This is good work. I think it'd be more useful for people if it were in patch format - especially as it's so few changes. A patch also summarizes everything you've put in above, in a format people can apply to their own copies of the module.
To do this, I've (a) changed your function names to term_node_count_* to avoid lots of erroneous patch lines and (b) rather reluctantly repeated the incorrect indentation of the original module. That way if a new version of tnc is released, then this patch will hopefully (almost) still apply cleanly.
Please find a patch attached, that should contain all relevant changes. I'm not 100% convinced it's getting its totals right yet, but ultimately the patch format means I can go back and look at what might be going wrong!
(This work was sponsored by Torchbox.)
Comment #5
jp.stacey commentedPatch attached.
Comment #6
jp.stacey commentedI can't get the node counting to work properly using this forked module as it stands (patch in #863460-5: Domain Access & i18n language specific counts.) There are a few bugs, including: it won't return the right stats when different revisions have different taxonomy terms; it doesn't count nodes for domain X which are sent to all affiliates and hence should count for domain Y too.
The following patch does the counting correctly, but it leads to duplicate entries in taxonomy-based views, one for each language and one for "language non-specific" (taxonomy-based views don't have any content negotiation argument in the same way that node views do.)
The only way I can see of taking the duplicates out is to remove i18n support and just do domains. I'll upload another patch shortly which hopefully tries this.
Comment #7
jp.stacey commentedHere's another patch, omitting i18n. This seems to work fine purely for domains. i18n is going to be trickier as it needs a views filter for taxonomies equivalent to Content Language Negotiation.
Comment #8
yngens commentedsubscribe
Comment #9
jp.stacey commentedThe original patch didn't take into account the fact that domain_access has duplicate records for nodes which are shared to all affiliates (i.e. across all domains). This was returning incorrect counts.
New patch attached.
Comment #10
jp.stacey commentedAnother bug to fix: sometimes, the root (ID=0) domain is submitted as ID=-1 during node save: patch re-rolled and attached.
Comment #11
jp.stacey commentedRe-rolled patch attached; the lack of initialization of
$saved_tidsinterm_node_cound_nodeapican sometimes lead to "unsupported operand" errors in the 'update' phase(It's not 100% clear to us how 'update' happens without 'presave' beforehand, but it could be something to do with our client site's rules configuration.)