I've got term_access working on a production 4.4.1 site, http://www.amcham.kz . However, just about every query that checks term_access is using up an enormous amount of MySQL's CPU cycles. The site has several extensive vocabularies, and with table joins being done on nearly every query about terms or nodes and comparisons with the large array of "accessible" terms, a lot of resources are being used just to deny access to a few items to anonymous users (which is an essential feature).

I've also noticed that basically, the patches rewrite all of the core modules queries for nodes, adding a table join to them, impacting performance.

Wouldn't it be possible to leave those queries alone, but add a call to a function in term_access that would check each nid against an array of denied terms and disallow access if the tid is found?

I realize that this is less secure, but I think it would be far more efficient, and give sites a "good enough" option to the much more complicated (and currently non-working) solution offered by groups.module.

It would also solve the problem related to the and vs or logic. Right now, because every node on my site has at least one term (if not more) from multiple vocabularies, in order to deny access to anything I must use the AND logic, which again puts more stress on the database. If the queries treated the term_access table as a list of denied tids, rather than allowed tids, that would eliminate this problem. If ANY of a node's tids were found in the deny table, access would be denied.

Comments

axel’s picture

Title: Access before deny? » SQL checks vs postSQL checks (was: Access before deny?)
Assigned: Unassigned » axel
Category: feature » task

> I've also noticed that basically, the patches rewrite all of the core
> modules queries for nodes, adding a table join to them, impacting
> performance.

Yes, of course :\ This is a same way as in the 'groups' module was
used. On early stage of 'term_access' development I ever use patches
from 'groups', simply convert them by sed (by replacing all 'groups'
insertions in text to 'term_access' - it was nearly compatible and
ever works :)

> Wouldn't it be possible to leave those queries alone, but add a call to
> a function in term_access that would check each nid against an array of
> denied terms and disallow access if the tid is found?

There is dilemma here:

1) in case when we get only records from node, who pass check in
INNER JOIN, queries become more complex (with DISTINCT MySQL
creates temporary table in such queries, additional JOIN eat time
time for large amount of tids...)

2) in case when we get all records from node, then check permissions,
we transfer unnecessary data from database. If RDBMS sits on
another host, we get network overhead, I think (not tested,
but IMHO) this is may hurt performance same way as in case 1.

I'm not sure which of variants is better. Now patches follow 1st way,
I'll try to adapt patches for alternate method, as you suggests above.

dmjossel’s picture

Alex,

Any progress on the proposed changes?

axel’s picture

Status: Active » Closed (won't fix)

In new versions of Drupal this module obsoleted by new permissions API. Module for old versions no supported anymore.