Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
taxonomy data
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
9 Apr 2009 at 09:06 UTC
Updated:
26 Jan 2011 at 00:00 UTC
After updating to Views 6.x-2.4, one of my views didn't work anymore.
It's using multiple taxonomy arguments, and the term_node tables in the query should be aliased but the aren't.
My temporary solution is to drop the first argument, create more views (one for each choice for the first argument), and emulate the first argument using filters.
Another solution would be to revert to the older 6.x-2.3 views module.
The query:
SELECT node.nid AS nid,
node.title AS node_title,
list_price,
sell_price,
node.type AS node_type,
node.vid AS node_vid,
RAND() AS _random
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
INNER JOIN term_data term_data ON term_node.tid = term_data.tid
LEFT JOIN term_node ON node.vid = .vid
WHERE (node.type in ('product')) AND (term_data.name = 'noutati') AND (term_data.name = 'pc')
ORDER BY _random ASC
The View:
$view = new view;
$view->name = 'speciale';
$view->description = 'Speciale';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Title',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'list_price' => array(
'label' => 'Pret recomandat',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'exclude' => 0,
'id' => 'list_price',
'table' => 'uc_products',
'field' => 'list_price',
'relationship' => 'none',
),
'sell_price' => array(
'label' => 'Pret vanzare',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'exclude' => 0,
'id' => 'sell_price',
'table' => 'uc_products',
'field' => 'sell_price',
'relationship' => 'none',
),
'field_image_cache_fid' => array(
'label' => 'Image',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'product_list_linked',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_image_cache_fid',
'table' => 'node_data_field_image_cache',
'field' => 'field_image_cache_fid',
'relationship' => 'none',
),
'tid' => array(
'label' => 'Platforma',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'type' => 'separator',
'separator' => ', ',
'empty' => '',
'link_to_taxonomy' => 0,
'limit' => 1,
'vids' => array(
'1' => 1,
'2' => 0,
'5' => 0,
'3' => 0,
'4' => 0,
'6' => 0,
),
'exclude' => 0,
'id' => 'tid',
'table' => 'term_node',
'field' => 'tid',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'random' => array(
'id' => 'random',
'table' => 'views',
'field' => 'random',
),
));
$handler->override_option('arguments', array(
'name' => array(
'default_action' => 'empty',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'toate',
'wildcard_substitution' => 'Toate',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'taxonomy_term',
'validate_fail' => 'empty',
'glossary' => 0,
'limit' => '0',
'case' => 'none',
'path_case' => 'lower',
'transform_dash' => 0,
'add_table' => 0,
'require_value' => 0,
'id' => 'name',
'table' => 'term_data',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'product' => 0,
'page' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'5' => 5,
'1' => 0,
'2' => 0,
'3' => 0,
'4' => 0,
'6' => 0,
),
'validate_argument_type' => 'name',
'user_argument_type' => '',
'restrict_user_roles' => 0,
'user_roles' => array(),
'validate_argument_php' => '',
),
'name_1' => array(
'default_action' => 'empty',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'toate-platformele',
'wildcard_substitution' => 'Toate platformele',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'taxonomy_term',
'validate_fail' => 'empty',
'glossary' => 0,
'limit' => '0',
'case' => 'none',
'path_case' => 'lower',
'transform_dash' => 0,
'add_table' => 0,
'require_value' => 0,
'id' => 'name_1',
'table' => 'term_data',
'field' => 'name',
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'product' => 0,
'page' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 1,
'2' => 0,
'5' => 0,
'3' => 0,
'4' => 0,
'6' => 0,
),
'validate_argument_type' => 'name',
'user_argument_type' => 'name',
'restrict_user_roles' => 0,
'user_roles' => array(),
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'product' => 'product',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'type_op',
'label' => 'Node: Type',
'use_operator' => FALSE,
'identifier' => 'type',
'remember' => FALSE,
'single' => TRUE,
'optional' => TRUE,
'reduce' => FALSE,
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 4);
$handler->override_option('use_pager', '0');
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
'grouping' => '',
'type' => 'ul',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'speciale');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));
Comments
Comment #1
radu_pantelica commentedLater edit:
Dropping the first argument, and setting it as a filter doesn't work either. The query turns to:
The query tries to find a node that is at the same time (same line in term_data) in two different categories. So it turns out an empty result.
Comment #2
fralenuvol commentedI had the same issues with views 6.x-2.4 on two different sites, one with the "migrate" module which makes use of views, ad the other with a simple view, similar to yours, which makes use of term_name as argument.
Investigating further, it seems that this bug occurs whenever the following function is called:
especially when the function is called with first argument $alias=NULL.
I am not a coder, anyway I found the following temporary solution, hoping that merlinofchaos will have a deeper look for a definitive fix:
in file "views/includes/handlers.inc" at line 578:
change:
to:
This way all my views work again with views 6.x-2.4.
Comment #3
ikarusweb commentedi have:
user warning: Not unique table/alias: 'term_node' query: SELECT node.nid AS nid, node.title AS node_title, street, additional, postal_code, city, province, country, field_regione_value, node.type AS node_type, node.vid AS node_vid, field_telefono_value FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid INNER JOIN term_data term_data ON term_node.tid = term_data.tid LEFT JOIN term_node ON node.vid = .vid WHERE (node.status <> 0) AND (node.type in ('cat')) AND (term_data.name = 'Alcatel') AND (term_data.name = 'Telefonia') ORDER BY node_title ASC in /Volumes/RAID/webfolders/stage/servicetrade/sites/all/modules/views/includes/view.inc on line 735.
and with #2 i have:
user warning: Unknown column 'term_data.name' in 'where clause' query: SELECT node.nid AS nid, node.title AS node_title, location.street AS location_street, location.additional AS location_additional, location.postal_code AS location_postal_code, location.city AS location_city, location.province AS location_province, location.country AS location_country, node_data_field_regione.field_regione_value AS node_data_field_regione_field_regione_value, node.type AS node_type, node.vid AS node_vid, node_data_field_regione.field_telefono_value AS node_data_field_regione_field_telefono_value FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_node term_data ON node.vid = term_data.vid LEFT JOIN term_data term_data__term_data ON term_data.tid = term_data__term_data.tid AND term_data__term_data.name != 'Alcatel' LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid LEFT JOIN location location ON location_instance.lid = location.lid LEFT JOIN content_type_cat node_data_field_regione ON node.vid = node_data_field_regione.vid WHERE (node.status <> 0) AND (node.type in ('cat')) AND (term_data.name = 'Alcatel') AND (term_data__term_data.name = 'Telefonia') ORDER BY node_title ASC in /Volumes/RAID/webfolders/stage/servicetrade/sites/all/modules/views/includes/view.inc on line 735.
who can help me?
Comment #5
merlinofchaos commentedThis is almost certainly related to a patch that came in that modifies the way arguments on the same many to one field can work together. For now you may be forced to downgrade to 2.3. =(
Comment #6
merlinofchaos commentedfralenuvol is correct, that does seem to fix the issue. Committed.
Radu, your problem may be partially related to the fact that you do not have the checkbox to allow the same field to cooperate, which should be necessary to have taxonomy: term as arguments twice.
Comment #7
fralenuvol commentedThanks merlinofchaos,
for your information, I found the same function call with first parameter NULL in many places, both inside views module, and other modules which make use of views.
For example in "schema" module a call to function "add_relationship(NULL, ....)" caused a similar issue and I corrected it in the same way.
So I don't know if this is to fix also in other places in views and other views-based modules, or if this is the only correction required.
Wanted just to advise you about that.
Comment #8
merlinofchaos commentedInterestingly enough, dww did the same check the day before I saw this issue about add_relationship, because it was messing up search. I believe all the instances in Views itself are now gone. If you do find that issue in other modules, it would be a good idea to file an issue against those modules and reference them to here, as it is obviously broken and won't be easy for someone to fix if they don't understand query::add_relationship() (which is very likely).
Comment #9
ppmax commentedHi--
I see there was a bug fix in the 2.5 changelog:
#428742 by fralenuvol: Fix broken relationship causing sql error with multiple taxonomy term arguments.
I have the same issue as #3: I was on views 2.3 and just upgraded to 2.5, ran update.php and everything broke with this output:
user warning: Unknown column 'term_data.name' in 'where clause' query: SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_node term_data ON node.vid = term_data.vid LEFT JOIN term_data term_data__term_data ON term_data.tid = term_data__term_data.tid AND term_data__term_data.name != 'Allu' WHERE (node.status <> 0) AND (node.type in ('products')) AND (term_data.name = 'Allu') AND (term_data__term_data.name = 'grinders') ORDER BY node_created DESC LIMIT 0, 10 in /home/.skoshy/extecadmin/screen2crush.com/sites/all/modules/views/includes/view.inc on line 731.Are there any known issues by downgrading to 2.3?
Thanks much--have a good Sunday.
pp
Comment #10
ppmax commentedOK--ignore #9. I think I panicked it being Sunday night and all ;)
One of my views has arguments like this:
taxonomy: term
taxonomy: term
node: title
I checked the checkbox for "Allow multiple arguments to work together" on both taxonomy: term arguments and all is well again.
setting status back to fixed. Sorry!
pp
Comment #12
rhythman commentedI am having the exact same issue as reported by radu_pantelica when I upgraded from 6x-2.3 to 6.x-2.5. I have two taxonomy term arguments, each in a different vocabulary. I tried the solution of checking the "Allow multiple arguments to work together" for but still get this error:
I am somewhat new to Drupal so I am not sure what other info to provide. It does seem to me that the line:
LEFT JOIN term_node term_data ON node.vid = term_data.vid
looks suspicious - creating a table alias that is the name of another table.
Comment #13
merlinofchaos commented'needs review' means there is a patch attached. Use active for bugs.
Comment #14
houen commented*BUMP* I have the same error with only one taxonomy argument, trying to allow multiple arguments to work together
Comment #15
houen commentedHmm - could this be the "fix" causing the error : http://drupal.org/node/388952
Comment #16
brush commentedbump
same problem, still not working for me in 2.6 or 2.x-dev
interestingly: the above "fix" of checking the appropriate boxes apparently solves the issue in preview, but not after the view is saved in production. caches all truncated, of course...
any ideas?
Comment #17
brush commentedindicating that current dev still isn't working
Comment #18
toddgee commentedHaving issues on 6.x-3.x-dev as well. I'm running tag DRUPAL-6--3 and am up-to-date. I have a view that needs to have two arguments that are both taxonomy terms. (Will use vocab1 and vocab2 for this discussion with terms term1a, term1b, term2a, term2b, etc.)
I've tried as a view with two arguments as one with with path path/term1/% where the first term was specified by a filter (with plans to duplicate the view for every term in vocab1). Neither work.
The first (two arguments) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_node term_data ON node.vid = term_data.vid
LEFT JOIN term_data term_data__term_data ON term_data.tid = term_data__term_data.tid AND term_data__term_data.name != 'nashville'
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_data.name = 'nashville') AND (term_data__term_data.name = 'lips')
Here 'nashville' is an element in vocab1 and 'lips' is in vocab2; these terms were selected in the preview. Obviously this fails -- there is no term_data.name (as term_data is an alias for the term_node field).
The second (one argument and one filter) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
INNER JOIN term_node term_node ON node.vid = term_node.vid
INNER JOIN term_data term_data ON term_node.tid = term_data.tid
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_node.tid = 10) AND (term_data.name = 'lips')
term id 10 is the filtered-on term from vocab1 (nashville) and lips is the argument term from vocab2. The issue (seems to be) that the term_data needs two aliases for the two term look ups but its using only one.
I'll monitor this thread and paste stuff as I find it.
Comment #19
toddgee commentedHaving issues on 6.x-3.x-dev as well. I'm running tag DRUPAL-6--3 and am up-to-date. I have a view that needs to have two arguments that are both taxonomy terms. (Will use vocab1 and vocab2 for this discussion with terms term1a, term1b, term2a, term2b, etc.)
I've tried as a view with two arguments as one with with path path/term1/% where the first term was specified by a filter (with plans to duplicate the view for every term in vocab1). Neither work.
The first (two arguments) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_node term_data ON node.vid = term_data.vid
LEFT JOIN term_data term_data__term_data ON term_data.tid = term_data__term_data.tid AND term_data__term_data.name != 'nashville'
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_data.name = 'nashville') AND (term_data__term_data.name = 'lips')
Here 'nashville' is an element in vocab1 and 'lips' is in vocab2; these terms were selected in the preview. Obviously this fails -- there is no term_data.name (as term_data is an alias for the term_node field).
The second (one argument and one filter) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
INNER JOIN term_node term_node ON node.vid = term_node.vid
drupal.orgdata term_data ON term_node.tid = term_data.tid
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_node.tid = 10) AND (term_data.name = 'lips')
term id 10 is the filtered-on term from vocab1 (nashville) and lips is the argument term from vocab2. The issue (seems to be) that the term_data needs two aliases for the two term look ups but its using only one.
I'll monitor this thread and paste stuff as I find it.
Comment #20
toddgee commentedHaving issues on 6.x-3.x-dev as well. I'm running tag DRUPAL-6--3 and am up-to-date. I have a view that needs to have two arguments that are both taxonomy terms. (Will use vocab1 and vocab2 for this discussion with terms term1a, term1b, term2a, term2b, etc.)
I've tried as a view with two arguments as one with with path path/term1/% where the first term was specified by a filter (with plans to duplicate the view for every term in vocab1). Neither work.
The first (two arguments) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_node term_data ON node.vid = term_data.vid
LEFT JOIN term_data term_data__term_data ON term_data.tid = term_data__term_data.tid AND term_data__term_data.name != 'nashville'
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_data.name = 'nashville') AND (term_data__term_data.name = 'lips')
Here 'nashville' is an element in vocab1 and 'lips' is in vocab2; these terms were selected in the preview. Obviously this fails -- there is no term_data.name (as term_data is an alias for the term_node field).
The second (one argument and one filter) generates SQL like this:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
INNER JOIN term_node term_node ON node.vid = term_node.vid
drupal.orgdata term_data ON term_node.tid = term_data.tid
WHERE (node.type in ('product')) AND (node.status <> 0) AND (term_node.tid = 10) AND (term_data.name = 'lips')
term id 10 is the filtered-on term from vocab1 (nashville) and lips is the argument term from vocab2. The issue (seems to be) that the term_data needs two aliases for the two term look ups but its using only one.
I'll monitor this thread and paste stuff as I find it.
Comment #21
rburgundy commentedsubscribing
Comment #22
testertesters commentedsubscribing
Comment #23
hongpong commentedsubscribing - looking for similar taxonomy arguments / joins
Comment #24
ericpai commentedsubscribing
Comment #25
Letharion commentedComment #26
merlinofchaos commentedI'm pretty sure this was fixed by #317271: ensure_my_table() Limited to One Relationship Per Table.
To be sure, I tested this (Views 2) with this view: