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:

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.

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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Zed Pobre’s picture

Project: Article » Taxonomy Access Control
FileSize
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:

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;

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.

Zed Pobre’s picture

FileSize
0 bytes

Trying again to attach the patch.

Zed Pobre’s picture

FileSize
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).

pyromanfo’s picture

Project: Taxonomy Access Control » Drupal core
Component: Code » taxonomy.module

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.

Dries’s picture

Committed to DRUPAL-4-5.

Anonymous’s picture