When asking for a list of nodes linked to more than one term by using the syntax 'taxonomy/term/x+y', the same nodes are shown twice instead of only one time, when nodes are linked to both x and y term.

Hoping I've been able to explain what happens.....
Matteo

PS: Maybe is it so by design.... ??

CommentFileSizeAuthor
#5 taxonomy_distinct.patch1.06 KBmatteo

Comments

matteo’s picture

It looks like a distinct(n.nid) clause should be added to lines 839-840, which should sound like this:

$sql = 'SELECT distinct(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC';
$sql_count = 'SELECT COUNT(distinct(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1';

this prints out the correct number of nodes.

Matteo

jonbob’s picture

Priority: Critical » Normal

I think your analysis is right. The DISTINCT() was probably removed because someone thought it was there for node permissions (the new db_rewrite() mechanism handles this now), but it is also necessary in the case of an OR query.

Cvbge’s picture

Hello,

I've used proposed change and it works as expected.

matteo’s picture

Just to undesrtand what to do, should I create the patch, or is it assigned to someone else ??
Matteo

matteo’s picture

Assigned: Unassigned » matteo
StatusFileSize
new1.06 KB

Here is the patch for Drupal 4.6 to solve this problem.
Matteo

dries’s picture

Committed to HEAD and DRUPAL-4-6. Thanks.

Anonymous’s picture