[drupal-devel] [bug] Nodes are repeated when asking for a list of taxonomy/term/x+y nodes

matteo drupal-devel at drupal.org
Fri May 20 13:00:16 UTC 2005


Issue status update for http://drupal.org/node/22469

 Project:      Drupal
 Version:      4.6.0
 Component:    taxonomy.module
 Category:     bug reports
 Priority:     normal
-Assigned to:  Anonymous
+Assigned to:  matteo
 Reported by:  matteo
 Updated by:   matteo
-Status:       active
+Status:       patch
 Attachment:   http://drupal.org/files/issues/taxonomy_distinct.patch (1.06 KB)

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




matteo



Previous comments:
------------------------------------------------------------------------

May 9, 2005 - 22:39 : matteo

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.... ??




------------------------------------------------------------------------

May 9, 2005 - 22:45 : matteo

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




------------------------------------------------------------------------

May 10, 2005 - 16:01 : JonBob

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.




------------------------------------------------------------------------

May 20, 2005 - 09:10 : Cvbge

Hello, 


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




------------------------------------------------------------------------

May 20, 2005 - 09:22 : matteo

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







More information about the drupal-devel mailing list