[drupal-devel] [bug] Article Categories display no entries for each category without "administer nodes" permission

pyromanfo drupal-devel at drupal.org
Sat Jan 29 15:50:26 UTC 2005


-Project:      Taxonomy Access Control
+Project:      Drupal
-Version:      4.5.0
+Version:      4.5.0
-Component:    Code
+Component:    taxonomy.module
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  Zed Pobre
 Updated by:   pyromanfo
 Status:       patch

Hey I don't know if you did this, but I just checked and it's not with my taxonomy.module patch at all, but with the core taxonomy.module.  I'll move it over there.

pyromanfo



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

December 21, 2004 - 19:06 : Zed Pobre

If a visiting user attempts to view more articles, all of the article categories will show 0 entries unless that user has administer nodes permission.  The following error will be seen in the logs:

<code>
user error: query: SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM term_node t INNER JOIN node_access na ON (na.nid = 0 OR na.nid = n.nid)INNER JOIN node n ON t.nid = n.nid WHERE n.status = 1 AND na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0')GROUP BY t.tid in /usr/local/share/drupal-4.5.1/includes/database.pgsql.inc on line 121.
</code>

This may be PostgreSQL-specific, but I have no MySQL install to test on.


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

January 22, 2005 - 09:53 : Zed Pobre

Attachment: http://drupal.org/files/issues/taxonomy_pgsql.patch (0 bytes)

It turns out, this error is coming from taxonomy.module, despite being triggered by article.module (and nowhere else that I can see).

As a first pass approximation, I think we want:

<code>
SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM term_node t INNER JOIN node n ON t.nid = n.nid INNER JOIN node_access na ON (na.nid = 0 OR na.nid = n.nid) WHERE n.status = 1 AND na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0') GROUP BY t.tid;
</code>

which I have converted from the error statement I'm seeing.  I've inverted the INNER JOIN order, putting node n before node_access na.  This seems to generate the right results, but I'm not absolutely confident in my SQL at this hour of the morning.

The attached patch to taxonomy.module implements this, fixes the problem with article.module on Postgres, and doesn't *seem* to have any negative side effects as far as I can see.  Please see if it looks reasonable to you.


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

January 22, 2005 - 09:54 : Zed Pobre

Attachment: http://drupal.org/files/issues/taxonomy_pgsql_0.patch (0 bytes)

Trying again to attach the patch.

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

January 22, 2005 - 09:55 : Zed Pobre

Attachment: http://drupal.org/files/issues/taxonomy_pgsql_1.patch (969 bytes)

Oh, right.  It's sitting on the other computer (I really wish Drupal would check for 0-byte attachments and throw a warning up somewhere to let you know that something was wrong).


-- 
View: http://drupal.org/node/14658
Edit: http://drupal.org/project/comments/add/14658





More information about the drupal-devel mailing list