Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If enabled the creation of new revisions to the nodes, the module considers not the number of nodes, and the number of revisions, which is false. It should be added to the query to calculate the expression
Now it looks:
SELECT COUNT(nid) FROM {term_node} WHERE tid = %d
It should be:
SELECT COUNT(<strong>DISTINCT</strong> nid) FROM {term_node} WHERE tid = %d
Comment | File | Size | Author |
---|---|---|---|
#10 | 640292-3-fax8.patch | 1.09 KB | fax8 |
#8 | 640292-2-fax8.patch | 1.24 KB | fax8 |
#7 | 640292-1.patch | 1.24 KB | fax8 |
#5 | taxblockpatch.txt | 2.08 KB | lurkerfilms |
Comments
Comment #1
ChemAli CreditAttribution: ChemAli commentedSorry, correct code:
SELECT COUNT(DISTINCT nid) FROM {term_node} WHERE tid = %d
Comment #2
ChemAli CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: fax8 commented@lurkerfilms seems you patched another module not taxonomy_block
Comment #7
fax8 CreditAttribution: fax8 commentedAttached a patch with the fixes in #4 which seems to work fine
Comment #8
fax8 CreditAttribution: fax8 commentedMmm.. seems that the patch above really didn't fix anything. Please test the following one.
Comment #9
tregismoreira CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: studgate commentedthis patch works perfectly.
Comment #12
BBCI'll second that. Works for me as well.