I was using the representative node feature to limit my View result to terms that only have content. I originally had this issue, updated to the dev. version, and it was working fine. After a period this feature stopped working. I am not able to fix the problem by changing settings.

My view has a contextual filter of a nid. It has two relationships. One is the taxonomy TIDs associated with the node, and the other is the representative node.

Full error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid' in 'where clause'

Specific version:

Drupal version : 7.14

version = "7.x-3.3+144-dev"
datestamp = "1337388799"

Full query string:

SELECT taxonomy_term_data_field_data_field_slks.name AS taxonomy_term_data_field_data_field_slks_na, taxonomy_term_data_field_data_field_slks.vid AS taxonomy_term_data_field_data_field_slks_vi, taxonomy_term_data_field_data_field_slks.tid AS taxonomy_term_data_field_data_field_slks_ti, taxonomy_term_data_field_data_field_slks__taxonomy_vocabulary.machine_name AS taxonomy_term_data_field_data_field_slks__t
FROM
{node} node
LEFT JOIN {field_data_field_slks} field_data_field_slks ON node.nid = field_data_field_slks.entity_id AND (field_data_field_slks.entity_type = 'node' AND field_data_field_slks.deleted = '0')
INNER JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_slks ON field_data_field_slks.field_slks_tid = taxonomy_term_data_field_data_field_slks.tid
INNER JOIN {node} node_taxonomy_term_data ON (SELECT nodeINNER.nid AS nidINNER
FROM
{node} nodeINNER
LEFT JOIN {taxonomy_index} taxonomy_indexINNER ON nodeINNER.nid = taxonomy_indexINNER.nid
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_nodeINNER ON taxonomy_indexINNER.tid = taxonomy_term_data_nodeINNER.tid
WHERE (( (taxonomy_term_data_nodeINNER.tid = taxonomy_term_data.tid ) ))
ORDER BY nodeINNER.title ASC
LIMIT 1 OFFSET 0) = node_taxonomy_term_data.nid
LEFT JOIN {taxonomy_vocabulary} taxonomy_term_data_field_data_field_slks__taxonomy_vocabulary ON taxonomy_term_data_field_data_field_slks.vid = taxonomy_term_data_field_data_field_slks__taxonomy_vocabulary.vid
WHERE (( (node.nid = '113342' ) )AND(( (node.status = '1') AND (node_taxonomy_term_data.type IN ('krames_staywell_article')) )))
ORDER BY taxonomy_term_data_field_data_field_slks_na ASC
LIMIT 5 OFFSET 0

The highlighted parts of the query are where the error is. Replacing the taxonomy_term_data with that alias gives the correct result.

A previous issue is located at http://drupal.org/node/1215468, but the "fix" was to say it was fixed in the dev. version (which I am using). If some enlightenment can be provided as to what the fix actually was, I'm more than happy to dig into the code myself. As it stands currently, I am not familiar enough with the inner working of Views to know what causes what.

CommentFileSizeAuthor
#21 view.txt15.33 KBLukas von Blarer
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

steven.wichers’s picture

I tracked the issue to line 299 of views/handlers/views_handler_relationship_groupwise_max.inc.

    // Replace the placeholder with the outer, correlated field.
    // Eg, change the placeholder ':users_uid' into the outer field 'users.uid'.
    // We have to work directly with the SQL, because putting a name of a field
    // into a SelectQuery that it does not recognize (because it's outer) just
    // makes it treat it as a string.
    $outer_placeholder = ':' . str_replace('.', '_', $this->definition['outer field']);
    $subquery_sql = str_replace($outer_placeholder, $this->definition['outer field'], $subquery_sql);

    return $subquery_sql;

$this->definition['outer field'] is the wrong value at the point of the str_replace.

trailrunner’s picture

Did you actually find the solution to the problem at line 299? I'm also receiving a similar error and would like to get it fixed. Thanks,

- TRT

steven.wichers’s picture

No, I wound up tweaking the logic behind the view (used a different term reference relationship) and the error was avoided.

capellic’s picture

I am having the same issue. This is the error I get in the preview:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid1' in 'where clause'

On the relationship modal, if I check "Generate subquery each time view is run" the preview works, but the view page does not work. Not only is this difference interesting and troubling, it's not as interesting and troubling as the fact that the view works fine in Dev but not in Production. It hasn't always been this way, in fact I had the production view working just last week.

I just cleared views cache. No change. Disabled views cache. No change.

The SQL generated by the view:

SELECT taxonomy_term_data.tid AS tid, taxonomy_term_data.name AS taxonomy_term_data_name, taxonomy_term_data.vid AS taxonomy_term_data_vid, taxonomy_vocabulary.machine_name AS taxonomy_vocabulary_machine_name, taxonomy_term_data.weight AS taxonomy_term_data_weight, 'taxonomy_term' AS field_data_field_url_filename_taxonomy_term_entity_type, 'taxonomy_term' AS field_data_field_abstract_taxonomy_term_entity_type
FROM 
{taxonomy_term_data} taxonomy_term_data
LEFT JOIN {node} node_taxonomy_term_data ON (SELECT nodeINNER.nid AS nidINNER
FROM 
{node} nodeINNER
LEFT JOIN {taxonomy_index} taxonomy_indexINNER ON nodeINNER.nid = taxonomy_indexINNER.nid
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_nodeINNER ON taxonomy_indexINNER.tid = taxonomy_term_data_nodeINNER.tid
WHERE (( (taxonomy_term_data_nodeINNER.tid = taxonomy_term_data.tid1 ) ))
ORDER BY nodeINNER.nid DESC
LIMIT 1 OFFSET 0) = node_taxonomy_term_data.nid
LEFT JOIN {taxonomy_vocabulary} taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
WHERE (( (taxonomy_vocabulary.machine_name IN  ('kyr_topics')) ))
ORDER BY taxonomy_term_data_weight ASC

Update

I can run the query directly on the DB without a problem.

kmajzlik’s picture

same here.
Caused by relationship "Representative node". Dev works well, production not (moved with Features).

But i comes only sometimes, on some displays.

ashii’s picture

Same here,
Could anyone suggest me a solution please ????? it's really urgent thank you.!

roxtaz’s picture

Subscribing this

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, 'node' AS field_data_field_reference_image_node_entity_type, 'node' AS field_data_taxonomy_vocabulary_1_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_taxonomy_vocabulary_1} field_data_taxonomy_vocabulary_1 ON node.nid = field_data_taxonomy_vocabulary_1.entity_id AND (field_data_taxonomy_vocabulary_1.entity_type = 'node' AND field_data_taxonomy_vocabulary_1.deleted = '0')
INNER JOIN {taxonomy_term_data} taxonomy_term_data_field_data_taxonomy_vocabulary_1 ON field_data_taxonomy_vocabulary_1.taxonomy_vocabulary_1_tid = taxonomy_term_data_field_data_taxonomy_vocabulary_1.tid
INNER JOIN {node} node_taxonomy_term_data ON (SELECT nodeINNER.nid AS nidINNER
FROM 
{node} nodeINNER
LEFT JOIN {taxonomy_index} taxonomy_indexINNER ON nodeINNER.nid = taxonomy_indexINNER.nid
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_nodeINNER ON taxonomy_indexINNER.tid = taxonomy_term_data_nodeINNER.tid
WHERE (( (taxonomy_term_data_nodeINNER.tid = taxonomy_term_data.tid ) ))
LIMIT 1 OFFSET 0) = node_taxonomy_term_data.nid
WHERE (( (node.status = '1') AND (node.type IN  ('produs')) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0

This is SQL for Representative node relationship in Views 3 followed by the error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid' in 'where clause'.

wak’s picture

Subscribing.

Same problem here as described in #4.

Dubs’s picture

Same problem here - I hope there's an answer soon...

Dubs’s picture

I have a workaround which involved the Views Field View. Grab this module and create a view to return one item and pass the term ID as an argument. This works the same, although I'm sure there is a larger performance hit doing things this way.

vibrasphere’s picture

Got exact error message like OP, I just removed Views (dev version) and replaced it back with 7.x-3.5 and flushed caches and works fine. 7.19 here.

vibrasphere’s picture

Looks like I was wrong. Like I posted my method above it worked, but it works until you run update.php to update any unrelated modules to views, it crashes again and gives me:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid' in 'where clause'

But again, I deleted Views directory and unpacked the latest dev version (not the recommended one) and flushed the caches and it all works again without any errors.

Since I am not a programmer, but a designer - all that is a mystery to me.

heatherwoz’s picture

I was having this problem too. One view was having trouble pulling the representative node. I had the relevant term field hidden from display on some content types. I enabled token display and made sure the field was displayed as token on all types. The error message went away and my view is working now. Seems like views shouldn't be reliant on the field display settings, but maybe it is. Or maybe this was just coincidence - can anyone reproduce?

Edit: I can confirm that in my case, enabling the relevant field in token display solved the issue, without even touching the view.

behemothhh’s picture

Hello everybody,

I'm experiencing the same nasty issue. Still no clues on a stable workaround?

edak’s picture

Did anyone find a solution? I'm having the same error!

andrewfasano’s picture

I was having the same issue as well. Heatherwoz's suggestion to change the field to display as a token fixed the error.

t7’s picture

Hi, i dont know if it would impact other part of your work, but this solution will omit that error:

Advanced -> Contextual filters
When the filter value is NOT available
Content: Nid -> Provide default value -> Type -> Content ID from URL

When the filter value IS available or a default is provided
Specify validation criteria -> Validator Content Content types -> Image (Your image content type)

FAAREIA’s picture

I'm not having this issue anymore in updated views 3.7 and drupal 7.22

Please confirm.

FAAREIA’s picture

Status: Active » Fixed

I'm in a production site with views 3.7 and drupal 7.22 and this bugs disappeared. Please re-open if you still have this issue with updated views and core.

Status: Fixed » Closed (fixed)

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

Lukas von Blarer’s picture

Status: Closed (fixed) » Active
FileSize
15.33 KB

I am still having this issue. I have multiple displays using different fields from the representative node relationship. When clearing cache it seems to quite randomly work and break again. Sometimes a part of the displays do work and others don't in various combinations.

I attached an export of my view.

Lukas von Blarer’s picture

Status: Active » Fixed

Updating from 7.x-3.7 to latest dev solved the issue for me.

Lukas von Blarer’s picture

Status: Fixed » Active

I posted to early... Still getting the error.

Lukas von Blarer’s picture

As stated in #1 this code replaces the placeholder:

<?php
    // Replace the placeholder with the outer, correlated field.
    // Eg, change the placeholder ':users_uid' into the outer field 'users.uid'.
    // We have to work directly with the SQL, because putting a name of a field
    // into a SelectQuery that it does not recognize (because it's outer) just
    // makes it treat it as a string.
    $outer_placeholder = ':' . str_replace('.', '_', $this->definition['outer field']);
    $subquery_sql = str_replace($outer_placeholder, $this->definition['outer field'], $subquery_sql);

    return $subquery_sql;
?>

But my query looks like this before:

SELECT nodeINNER.nid AS nidINNER
FROM 
{node} nodeINNER
LEFT JOIN {taxonomy_index} taxonomy_indexINNER ON nodeINNER.nid = taxonomy_indexINNER.nid
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_nodeINNER ON taxonomy_indexINNER.tid = taxonomy_term_data_nodeINNER.tid
WHERE (( (taxonomy_term_data_nodeINNER.tid = taxonomy_term_data.tid5 ) ))
ORDER BY nodeINNER.nid DESC
LIMIT 1 OFFSET 0

But $this->definition['outer field'] is always this:

:taxonomy_term_data_tid

So, this number is being left over. I did not really understand any logic behind this number. On my view it differs from display to display. Where could this number be coming from? I guess I will have to switch over to a node based view for now...

Elin Yordanov’s picture

Checking this option has resolved my problem:
"Generate subquery each time view is run. "
But it is indicated that this option seriously impairs performance.

You can find this option on the configure relationship menu.

Edit: I also entered a namespace for the subquery.

Lukas von Blarer’s picture

I tried both options without success.

Elin Yordanov’s picture

I was also too early to post. The problem occurred again after a few days. But at first time it was gone. So this can be a point to track down the problem itself.

XaviP’s picture

Version: 7.x-3.x-dev » 7.x-3.7

Same error here: (Drupal 7.22 - Views 7.x-3.7)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid1' in 'where clause'

Query:

SELECT node_taxonomy_term_data.nid AS node_taxonomy_term_data_nid, node_taxonomy_term_data.title AS node_taxonomy_term_data_title, 'node' AS field_data_field_imagen_listado_node_entity_type, 'node' AS field_data_body_node_entity_type
FROM 
{taxonomy_term_data} taxonomy_term_data
LEFT JOIN {node} node_taxonomy_term_data ON (SELECT nodeINNER.nid AS nidINNER
FROM 
{node} nodeINNER
LEFT JOIN {taxonomy_index} taxonomy_indexINNER ON nodeINNER.nid = taxonomy_indexINNER.nid
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_nodeINNER ON taxonomy_indexINNER.tid = taxonomy_term_data_nodeINNER.tid
WHERE (( (taxonomy_term_data_nodeINNER.tid = taxonomy_term_data.tid1 ) ))
ORDER BY nodeINNER.created DESC
LIMIT 1 OFFSET 0) = node_taxonomy_term_data.nid
LEFT JOIN {taxonomy_vocabulary} taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
WHERE (( (taxonomy_vocabulary.machine_name IN  ('tags')) ))
LIMIT 7 OFFSET 0

I have two displays in the same view: the first is correctly running with "taxonomy_term_data.tid", but the second one not with "taxonomy_term_data.tid1"
I need two displays: one for thumbnails and one with slider, both connected with flexslider.

Has anyone find a solution? Thank you.

XaviP’s picture

I've tried to separate both displays in separate views, with the same result.
I've tried to make the slider view with two views and module views in views (child view with content and context filter (content:tag), parent view with taxonomy terms, and a contextual filter in views in views field [!name] This works with any format (unsorted list, grid, etc...) but not with flexslider format (doesn't recognize the images in the views in views field). Maybe this is usefull for someone who don't use flexslider format view.

Any idea how to repare it? Thankyou.

shrop’s picture

I am having the error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.tid1' in 'where clause'. I have two views using tid_representative. One works fine and the other has the error.

mnapier’s picture

I've got the same problem using the representative node relationship. I have noticed if I clear the cache (admin menu flush all caches) while on the views edit page then the view starts working, although after a while it stops and I have to go into the edit screen and flush the caches again. I don't know why that works.

It'd be great to have a real fix, clearing the cache every time I notice the problem isn't really a great solution :)

Here's an export of the view incase that helps.
Core is 7.22 and views is 7.x-3.7

$view = new view();
$view->name = 'dashboard_children';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Dashboard Children';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  2 => '2',
);
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'term-[tid]';
$handler->display->display_options['row_plugin'] = 'fields';
/* Footer: Global: Text area */
$handler->display->display_options['footer']['area']['id'] = 'area';
$handler->display->display_options['footer']['area']['table'] = 'views';
$handler->display->display_options['footer']['area']['field'] = 'area';
$handler->display->display_options['footer']['area']['content'] = '<div style="clear: both;"></div>';
$handler->display->display_options['footer']['area']['format'] = 'full_html';
/* Relationship: Taxonomy term: Representative node */
$handler->display->display_options['relationships']['tid_representative']['id'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['tid_representative']['field'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['required'] = TRUE;
$handler->display->display_options['relationships']['tid_representative']['subquery_sort'] = 'node.nid';
$handler->display->display_options['relationships']['tid_representative']['subquery_view'] = '';
$handler->display->display_options['relationships']['tid_representative']['subquery_namespace'] = '';
/* Field: Taxonomy term: Term ID */
$handler->display->display_options['fields']['tid']['id'] = 'tid';
$handler->display->display_options['fields']['tid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['tid']['field'] = 'tid';
$handler->display->display_options['fields']['tid']['label'] = '';
$handler->display->display_options['fields']['tid']['exclude'] = TRUE;
$handler->display->display_options['fields']['tid']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['tid']['separator'] = '';
/* Field: Taxonomy term: Logo */
$handler->display->display_options['fields']['field_logo']['id'] = 'field_logo';
$handler->display->display_options['fields']['field_logo']['table'] = 'field_data_field_logo';
$handler->display->display_options['fields']['field_logo']['field'] = 'field_logo';
$handler->display->display_options['fields']['field_logo']['relationship'] = 'parent';
$handler->display->display_options['fields']['field_logo']['label'] = '';
$handler->display->display_options['fields']['field_logo']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['field_logo']['alter']['path'] = 'dashboard/[tid]';
$handler->display->display_options['fields']['field_logo']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_logo']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_logo']['settings'] = array(
  'image_style' => 'thumbnail',
  'image_link' => '',
);
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'parent';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
/* Sort criterion: Taxonomy term: Weight */
$handler->display->display_options['sorts']['weight']['id'] = 'weight';
$handler->display->display_options['sorts']['weight']['table'] = 'taxonomy_term_data';
$handler->display->display_options['sorts']['weight']['field'] = 'weight';
/* Contextual filter: Taxonomy term: Parent term */
$handler->display->display_options['arguments']['parent']['id'] = 'parent';
$handler->display->display_options['arguments']['parent']['table'] = 'taxonomy_term_hierarchy';
$handler->display->display_options['arguments']['parent']['field'] = 'parent';
$handler->display->display_options['arguments']['parent']['default_action'] = 'not found';
$handler->display->display_options['arguments']['parent']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['parent']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['parent']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['parent']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['parent']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['parent']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['parent']['validate']['type'] = 'taxonomy_term';
$handler->display->display_options['arguments']['parent']['validate_options']['vocabularies'] = array(
  'events' => 'events',
);
$handler->display->display_options['arguments']['parent']['validate']['fail'] = 'empty';
/* Filter criterion: Content access: Access */
$handler->display->display_options['filters']['nid']['id'] = 'nid';
$handler->display->display_options['filters']['nid']['table'] = 'node_access';
$handler->display->display_options['filters']['nid']['field'] = 'nid';
$handler->display->display_options['filters']['nid']['relationship'] = 'tid_representative';

/* Display: Content pane */
$handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1');
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Taxonomy term: Representative node */
$handler->display->display_options['relationships']['tid_representative']['id'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['tid_representative']['field'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['required'] = TRUE;
$handler->display->display_options['relationships']['tid_representative']['subquery_sort'] = 'node.nid';
$handler->display->display_options['relationships']['tid_representative']['subquery_view'] = '';
$handler->display->display_options['relationships']['tid_representative']['subquery_namespace'] = '';
$handler->display->display_options['argument_input'] = array(
  'parent' => array(
    'type' => 'context',
    'context' => 'entity:taxonomy_term.tid',
    'context_optional' => 0,
    'panel' => '0',
    'fixed' => '',
    'label' => 'Taxonomy term: ID',
  ),
);

/* Display: Super Users */
$handler = $view->new_display('panel_pane', 'Super Users', 'panel_pane_2');
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
$handler->display->display_options['argument_input'] = array(
  'parent' => array(
    'type' => 'context',
    'context' => 'entity:taxonomy_term.tid',
    'context_optional' => 0,
    'panel' => '0',
    'fixed' => '',
    'label' => 'Taxonomy term: Parent term',
  ),
);

/* Display: Parent Children */
$handler = $view->new_display('panel_pane', 'Parent Children', 'panel_pane_3');
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Taxonomy term: Representative node */
$handler->display->display_options['relationships']['tid_representative']['id'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['tid_representative']['field'] = 'tid_representative';
$handler->display->display_options['relationships']['tid_representative']['required'] = TRUE;
$handler->display->display_options['relationships']['tid_representative']['subquery_sort'] = 'node.nid';
$handler->display->display_options['relationships']['tid_representative']['subquery_view'] = '';
$handler->display->display_options['relationships']['tid_representative']['subquery_namespace'] = '';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Taxonomy term: Term ID */
$handler->display->display_options['fields']['tid']['id'] = 'tid';
$handler->display->display_options['fields']['tid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['tid']['field'] = 'tid';
$handler->display->display_options['fields']['tid']['label'] = '';
$handler->display->display_options['fields']['tid']['exclude'] = TRUE;
$handler->display->display_options['fields']['tid']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['tid']['separator'] = '';
/* Field: Taxonomy term: Logo */
$handler->display->display_options['fields']['field_logo']['id'] = 'field_logo';
$handler->display->display_options['fields']['field_logo']['table'] = 'field_data_field_logo';
$handler->display->display_options['fields']['field_logo']['field'] = 'field_logo';
$handler->display->display_options['fields']['field_logo']['label'] = '';
$handler->display->display_options['fields']['field_logo']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['field_logo']['alter']['path'] = 'dashboard/[tid]';
$handler->display->display_options['fields']['field_logo']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_logo']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_logo']['settings'] = array(
  'image_style' => 'thumbnail',
  'image_link' => '',
);
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['defaults']['sorts'] = FALSE;
/* Sort criterion: Taxonomy term: Weight */
$handler->display->display_options['sorts']['weight']['id'] = 'weight';
$handler->display->display_options['sorts']['weight']['table'] = 'taxonomy_term_data';
$handler->display->display_options['sorts']['weight']['field'] = 'weight';
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Taxonomy term: Parent term */
$handler->display->display_options['arguments']['parent']['id'] = 'parent';
$handler->display->display_options['arguments']['parent']['table'] = 'taxonomy_term_hierarchy';
$handler->display->display_options['arguments']['parent']['field'] = 'parent';
$handler->display->display_options['arguments']['parent']['default_action'] = 'default';
$handler->display->display_options['arguments']['parent']['default_argument_type'] = 'php';
$handler->display->display_options['arguments']['parent']['default_argument_options']['code'] = '$parent = array_shift(taxonomy_get_parents(arg(1)));
if(isset($parent->tid)) {
return $parent->tid;
}
';
$handler->display->display_options['arguments']['parent']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['parent']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['parent']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['argument_input'] = array(
  'tid' => array(
    'type' => 'none',
    'context' => 'entity:comment.author',
    'context_optional' => 0,
    'panel' => '0',
    'fixed' => '',
    'label' => 'Taxonomy term: Term ID',
  ),
);
mnapier’s picture

This definitely is not a permanent fix but I did a quick query alter on the view to remove the extra digit from the query. It works for me until a proper fix comes out.

function YOURMODULE_views_query_alter(&$view, &$query) {
  if ($view->name == 'YOUR_VIEW_NAME') {
    $view->query->table_queue['node_taxonomy_term_data']['join']->left_query = preg_replace('/tid[0-9]/', 'tid', $view->query->table_queue['node_taxonomy_term_data']['join']->left_query);
  }
return $view;
}
shrop’s picture

Very clever!

Elin Yordanov’s picture

The workaround on #32 works like charm. Thanks a lot mnapier, you saved my day.

XaviP’s picture

Wow! That works for me! Thank you, mnapier!

13rac1’s picture

Version: 7.x-3.7 » 7.x-3.x-dev

I am getting this error and #1417090: Taxonomy term "Representative node" views with filters and sorts don't work in the same View. Might be helpful for debugging.

13rac1’s picture

I went down the rabbit hole to find this incorrect placeholder. The path:

  1. views_handler_relationship_groupwise_max->left_query()
  2. view->build()
  3. views_handler_argument_numeric->query()
  4. views_handler_argument_numeric->placeholder()

The placeholder is created in plugins/views_plugin_query_default.inc

function placeholder($base = 'views') {
  static $placeholders = array();
  if (!isset($placeholders[$base])) {
    $placeholders[$base] = 0;
    return ':' . $base;
  }
  else {
    return ':' . $base . ++$placeholders[$base];
  }
}

Details: https://api.drupal.org/api/views/plugins%21views_plugin_query_default.in...

The issue is that $placeholders is a static. Every new placeholder, after the first, with the same name is going to have a number at the end of it.

The placeholder will not be incremented if the subqueries are built in separate PHP calls since they are cached. When the Drupal cache is cleared, all displayed will are rebuilt at the same time, so the placeholder is incremented. That's the reason I didn't encounter this issue until I cleared the Drupal cache. "Generate subquery each time view is run" fixes the problem in Preview Only, because only one subquery is generated per PHP call.

Patch shortly.

13rac1’s picture

Status: Active » Closed (duplicate)

Ok. The fix for this is heavily related to and uses/modifies code from #1417090: Taxonomy term "Representative node" views with filters and sorts don't work. I am setting this issue to duplicate, because I've fixed(hopefully!) this issue is there. The patch makes the placeholder's name is irrelevant, it is always replaced with the correct value. The patch is in: https://drupal.org/node/1417090#comment-7856511

13rac1’s picture

13rac1’s picture

Issue summary: View changes

Highlighted first part of mismatch

marfi’s picture

Issue summary: View changes

Hi, I'm having the same issue.

Exaclty the same behaviour, sometimes it works sometimes not, If I clear cache stops working.
Doesn't matter if views are in different pages or in the same page.

Drupal version: 7.50
View version: 7.x-3.14

Is it possible that for some reason there is a software regression?

Thanks