I use domain_taxonomy, which provides taxonomy terms visibility on per-domain basis (similar to what domain does for nodes). I have a content type with two term reference fields, same Vocabulary but different widgets. On node form the Select list widget correctly presents only the terms assigned to the current domain, while the Hierarchical Select widget presents all vocabulary terms, irrespective of current domain. Note that in D6 HS was honoring the domain assignments, so it may be something lost in the upgrade. Thank you

CommentFileSizeAuthor
#7 D7-API-query-1394416-7.patch1.1 KBzechola

Comments

skizzo’s picture

Version: 7.x-3.0-alpha5 » 7.x-3.x-dev
alan d.’s picture

Title: Port support for domain_taxonomy from D6 to D7 » Term access bypass
Category: task » bug
Priority: Normal » Critical
Issue tags: +Security

I was helping to fix an issue in Domain Taxonomy and the noticed that term access was being bypassed. This should be tagged with term_access

One example query is:

    // TODO Please convert this statement to the D7 database API
syntax.
    $result = db_query('SELECT t.tid, t.*, parent FROM
{taxonomy_term_data} t INNER JOIN  {taxonomy_term_hierarchy} h ON t.tid
= h.tid WHERE t.vid = :vid ORDER BY weight, name', array(':vid' =>
$vid));

see taxonomy_get_tree() for an example.

wim leers’s picture

Status: Active » Needs work

So something like:

$query = db_select('taxonomy_term_data', 't');
    $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
    $result = $query
      ->addTag('translatable')
      ->addTag('term_access')
      ->fields('t')
      ->fields('t', array('parent'))
      ->condition('t.vid', $vid)
      ->orderBy('t.weight')
      ->orderBy('t.name')
      ->execute();

? Since you're actually using this, I'd appreciate it if you could roll a patch based on the above, test it and report it back :)

alan d.’s picture

I was helping out with Domain Taxonomy which is vital for a project that we are working on, and there was an issue there that suggested that it had this issue. So 2 hours solid debugging failed to find issues there, I tracked the issue down to this module instead.

The parent field looks wrong above, shouldn't this be:

      ->fields('t')
-      ->fields('t', array('parent'))
+      ->fields('h', array('parent'))
wim leers’s picture

You're absolutely right!

zechola’s picture

I'm running into this issue, too, but changes don't seem to be in the dev release. Would anyone like to help roll up a patch?

zechola’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

I made the above changes and created a patch. Please review it. Ideally we'll add more for the other queries but this is a fix for this particular issue.

skizzo’s picture

Can't say about "other queries", but after applying above patch to 7.x-3.0-alpha5+9-dev the problem is gone.
Thanks to Alan D. and zechola (sorry Wim, I couldn't roll a patch as I have no coding experience whatsoever...)

wim leers’s picture

Title: Term access bypass » Integrate with Term Access
Category: bug » feature
Priority: Critical » Normal
Status: Needs review » Fixed
Issue tags: -Security

This is not really a bug, neither a security problem. The problem is that the term_access module cannot enforce anything because it is not part of the Drupal core taxonomy module. It cannot be regarded as a bug, only as a feature request.

That being said, #7 was confirmed by #8, so I've committed it :)

Thanks!

http://drupalcode.org/project/hierarchical_select.git/commit/a79c119

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.