Needs review
Project:
Taxonomy Block
Version:
6.x-1.0-beta6
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Nov 2009 at 08:21 UTC
Updated:
7 Dec 2010 at 20:45 UTC
Jump to comment: Most recent file
Comments
Comment #1
ChemAli commentedSorry, correct code:
SELECT COUNT(DISTINCT nid) FROM {term_node} WHERE tid = %d
Comment #2
ChemAli commentedThe module counts unpublished nodes too, which is wrong in most cases and requires correction.
Comment #3
elioshNode count is also wrng when using i18n.
I have a vocab with " Localize terms. Terms are common for all languages, but their name and description may be localized. " multilanguage settings, so i have the same tid for each translation.
When looking the site in english, it shows term in english. If looking the site in italian, i saw term in italian. OK
But if i activate NODE COUNT setting, it shows (2) nodes with a predefined term, while instead it's only one (per language).
I hope I was clear in my explanation.
Comment #4
elioshi think that a query like this probably will solve the problem (at least for me :-D )
from :
to
Comment #5
lurkerfilms commentedYes this is a bug because revisions were not taken into consideration.
Instead of doing DISTINCT in the query, the following condition should be added to the two queries that do the count:
AND n.vid = tn.vid
This only looks at the current revision and ignores all the historic revisions.
Likewise the term_has_nodes should do likewise.
Patch is attached.
Comment #6
fax8 commented@lurkerfilms seems you patched another module not taxonomy_block
Comment #7
fax8 commentedAttached a patch with the fixes in #4 which seems to work fine
Comment #8
fax8 commentedMmm.. seems that the patch above really didn't fix anything. Please test the following one.
Comment #9
tregismoreira commentedI downloaded the taxonomy_block-6.x-1.0-beta6 and the problem with duplicity on behalf of reviews (the original subject of this topic) is still occurring. Looking at the code, I could see that was already implemented the solution for the counting of nodes not published but was not implemented solution for nodes with revisions.
So I changed the code as follows.
Line 105, from:
$sql_count_parents = "SELECT COUNT (tn.nid) FROM {tn} term_node "to:
$sql_count_parents = "SELECT COUNT (DISTINCT (tn.nid)) FROM {tn} term_node "Line 114, from:
$sql_count_childs = "SELECT count (td.tid) from {} td term_data "to:
$sql_count_childs = "SELECT count (DISTINCT (td.tid)) from {} td term_data "For me, this change solved the problem. Anyone can evaluate and create a patch?
Comment #10
fax8 commentedGood work tregismoreira. Attached there is a patch with your changes. I also fixed some bad parenthesis.
This is a critical issue for this module. Any maintainer willing to commit this issue and release another version?
Comment #11
studgate commentedthis patch works perfectly.
Comment #12
bbcI'll second that. Works for me as well.