I have view that's failing to display any nodes. I've tracked the issue down to tac_lite_query_term_access_alter().

The code in there is identifies 'node' as the $primary table then attempts to join taxonomy_term_data.tid against node.tid causing an sql error.

The nodes I am trying to display are of Content Type 'pressrelease' which contains a Term reference field 'taxonomy_vocabulary_8'. The term is represented in the database by the table 'field_data_taxonomy_vocabulary_8' which has a field 'taxonomy_vocabulary_8_tid'.

Dump of $t ($query->getTables()) is :

Array
(
    [node] => Array
        (
            [join type] => 
            [table] => node
            [alias] => node
            [condition] => 
            [arguments] => Array
                (
                )

        )

    [field_data_taxonomy_vocabulary_8] => Array
        (
            [join type] => LEFT
            [table] => field_data_taxonomy_vocabulary_8
            [alias] => field_data_taxonomy_vocabulary_8
            [condition] => node.nid = field_data_taxonomy_vocabulary_8.entity_id AND (field_data_taxonomy_vocabulary_8.entity_type = :views_join_condition_0 AND field_data_taxonomy_vocabulary_8.deleted = :views_join_condition_1)
            [arguments] => Array
                (
                    [:views_join_condition_0] => node
                    [:views_join_condition_1] => 0
                )

        )

    [taxonomy_term_data_field_data_taxonomy_vocabulary_8] => Array
        (
            [join type] => LEFT
            [table] => taxonomy_term_data
            [alias] => taxonomy_term_data_field_data_taxonomy_vocabulary_8
            [condition] => field_data_taxonomy_vocabulary_8.taxonomy_vocabulary_8_tid = taxonomy_term_data_field_data_taxonomy_vocabulary_8.tid
            [arguments] => Array
                (
                )

        )

    [na] => Array
        (
            [join type] => INNER
            [table] => node_access
            [alias] => na
            [condition] => na.nid = node.nid
            [arguments] => Array
                (
                )

        )

)

Appears to be a bug in how it identifies the tid, but I'm unsure how to fix. Please let me know if I can provide any more information.

CommentFileSizeAuthor
#4 patch-tac-lite-visibility-join.patch22.86 KBcocorodeo

Comments

hanoii’s picture

This also happened to me, there's something wrong in that logic.

In my case, I have a node that has two taxonomy fields. Then I have a view that lists those nodes, then adds a relationship to its taxonomy term data and each taxonomy term relationhship is again related to one content of another type that also is tagged by that taxonomy. This works with admin but tac_lite messes up the query with this same error (node.tid which doesn't exists).

In my case, I just disabled views node access tags to workaround this.

Dave Cohen’s picture

Status: Active » Postponed (maintainer needs more info)

That hook is passed a barely-documented thing called a QueryAlterableInterface.

It tries to learn the name of the query's primary table, but it has to guess. See the inline comment that starts "HELP..."

It sounds very complicated to try to reproduce your cases. Can you add this debug code to tac_lite.module and let me know what you see?

diff --git a/tac_lite.module b/tac_lite.module
index c825c6f..d5345a4 100644
--- a/tac_lite.module
+++ b/tac_lite.module
@@ -663,6 +663,7 @@ function tac_lite_query_term_access_alter(QueryAlterableInterface $query) {
     $primary_table = '';
     $t = $query->getTables();
     foreach($t as $key => $info) {
+      dpm($info, __FUNCTION__ . " $key");
       if (!$info['join type']) {
         $primary_table = $info['alias'];
       }
colinodell’s picture

I'm also seeing this exact same behavior and error.

Our workaround was to add this line right before the $query->leftJoin():

if ($primary_table === 'node') return;

Why? Because the node table doesn't have a tid column, so we know the query will always fail in those cases. The other nice thing about this workaround is that it doesn't impact valid usages where this function works, nor does it require disabling any other permission checks.

cocorodeo’s picture

StatusFileSize
new22.86 KB

Hi guys,

I posted comments on another issue #2850750
but I think it's more related to te current issue.

Here is a workaround I've done to achieve fixing sql errors on non-existing table for the visibility LEFT OUTER JOIN

I'm joining a patch I'v done ... Comments and corrections are welcome.