STEPS TO REPRODUCE
- Enable 2 languages
- Create a new content type: news
- Enable it for translation
- Create a new vocabulary: categories
- Enable it for translation
- Create a taxonomy reference on content type news which is language neutral
- Create a View (it should show for current language on the page) and create a filter on the categories term
- Create the node in primary language
- Translate the node to the secondary language
- Try filter the node with the term filter on secondary language, and it won't display
I have a content type News.
I have a vocabulary Categories.
The Categories are translatable.
The News are translatable.
The taxonomy reference on News are language neutral and should be shared on the news translations.
Drupal version: 8.2.1
PHP version: 5.5.9
Web server: Apache
OS: Ubuntu 14.04
On the taxonomy term field, the langcode is stored on the node first created. So If I create an english node first, it's "en" and If I create a French one, it's fr.
This is a problem, because now I cannot filter on the categories on the translated language: The SQL produced by looks like:
SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
INNER JOIN {node__field_news_main_categories} node__field_news_main_categories ON node_field_data.nid = node__field_news_main_categories.entity_id AND (node__field_news_main_categories.deleted = '0' AND node__field_news_main_categories.langcode = node_field_data.langcode)
WHERE (( (node__field_news_main_categories.field_news_main_categories_target_id = '89') )AND(( (node_field_data.status = '1') AND (node_field_data.type IN ('news')) AND (node_field_data.langcode IN ('fr')) )))
ORDER BY node_field_data_created DESC
LIMIT 10 OFFSET 0
Since the taxonomy term is LANGUAGE NEUTRAL on the node, shouldn't it store the reference with langcode und?
The easiset solution, I guess would be to determine if the field is language neutral and if so remove this part:
AND node__field_news_main_categories.langcode = node_field_data.langcode
Here's the view:
uuid: 1d45dfb3-edbd-493d-bcaf-dec0e12931c0
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- node.type.news
- taxonomy.vocabulary.content_categories_main
module:
- node
- search
- taxonomy
- user
id: news_article_list
label: 'News/article list'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
tags:
previous: ''
next: ''
first: ''
last: ''
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: 'entity:node'
options:
relationship: none
view_mode: teaser
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
news: news
entity_type: node
entity_field: type
plugin_id: bundle
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
operator: '>='
value:
min: ''
max: ''
value: ''
type: date
group: 1
exposed: true
expose:
operator_id: created_op
label: 'Authored on'
description: ''
use_operator: false
operator: created_op
identifier: custom_date_filter_down
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
editor: '0'
webmaster: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: node
entity_field: created
plugin_id: date
field_news_main_categories_target_id:
id: field_news_main_categories_target_id
table: node__field_news_main_categories
field: field_news_main_categories_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_news_main_categories_target_id_op
label: 'Main category'
description: ''
use_operator: false
operator: field_news_main_categories_target_id_op
identifier: main_category
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
editor: '0'
webmaster: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
type: select
limit: true
vid: content_categories_main
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
keys:
id: keys
table: node_search_index
field: keys
relationship: none
group_type: group
admin_label: ''
operator: optional
value: ''
group: 1
exposed: true
expose:
operator_id: keys_op
label: Search
description: ''
use_operator: false
operator: keys_op
identifier: search
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
editor: '0'
webmaster: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: search_keywords
sorts:
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
order: DESC
exposed: false
expose:
label: ''
granularity: second
entity_type: node
entity_field: created
plugin_id: date
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
css_class: 'date-filter-workaround-form'
rendering_language: '***LANGUAGE_language_interface***'
cache_metadata:
max-age: -1
contexts:
- 'languages:language_interface'
- url
- url.query_args
- user
- 'user.node_grants:view'
- user.permissions
tags: { }
Comment | File | Size | Author |
---|---|---|---|
#18 | language_neutral-2829921-18.patch | 1.2 KB | yogeshmpawar |
#11 | drupal-filter-taxonomy-on-translated-content-2829921-6-8.x.patch | 1.2 KB | dzinkevich |
Comments
Comment #2
johnwebdev CreditAttribution: johnwebdev commentedComment #3
johnwebdev CreditAttribution: johnwebdev commentedComment #4
johnwebdev CreditAttribution: johnwebdev commentedComment #5
johnwebdev CreditAttribution: johnwebdev commentedSo I've tracked the issue down to views.view.inc on
views_field_default_views_data()
And the issue can be solved by removing:
array('left_field' => 'langcode', 'field' => 'langcode'),
. However, we should probably determine if the field is translatable, and conditionally add it.Comment #6
johnwebdev CreditAttribution: johnwebdev commentedThat seemed to work as expected. Here's a Terminal diff just to show what I did, I'll let some people put in some thoughts before I actually submit it:
Comment #7
cilefen CreditAttribution: cilefen commentedHi @johndevman:
This is a detailed error report. But, it does not meet the criteria for being a critical issue.
Comment #9
shaalworking on triaging this issue in Drupalcon Baltimore 2017 sprint
Comment #10
shaalI was able to reproduce this issue on 8.4.x
Cannot test the fix submitted by #6 because it's just a text comment and not a patch file.
Comment #11
dzinkevich CreditAttribution: dzinkevich at Zivtech commentedHere's a proper patch for #6.
I have not tested it for accuracy.
The code looks like it will do the right thing. I think there should be a better name for the $extra_data variable.
Comment #12
dzinkevich CreditAttribution: dzinkevich at Zivtech commentedComment #13
shaalComment #14
johnwebdev CreditAttribution: johnwebdev commentedI agree dzinkevich, we should just be able to call it $extra, I suppose? We could also omit the === TRUE part, since the method does always return a boolean, and using is in the prefix indicates that is an boolean as well.
Thanks for attaching it as a proper patch.
Comment #16
cilefen CreditAttribution: cilefen commented@shaal I am going over the issues analyzed at the Baltimore triage in order to assign credit. I would like to give you credit for the work done, but I can't tell whether or not all steps of the triage were completed by reading the comments. We like to see documented steps (even if brief). Here are some made-up examples of documented triage steps:
Comment #17
shaalI was able to reproduce the bug on Drupal 8.4.x clean installation.
I followed the steps that were already described beforehand -
I checked the issue summary and it is accurate and up-to-date.
I couldn't any similar/duplicate issues.
I could not apply the patch submitted by @dzinkevich
Comment #18
yogeshmpawarRe-roll the #11 patch because it's failed to apply on 8.4.x branch.
Comment #19
cilefen CreditAttribution: cilefen commentedI am updating credit - thank you @shaal!
Comment #21
ollu CreditAttribution: ollu commentedToday I updated from 8.3.7 to 8.4 and since we had the issue before I tried applying the patch but did not succeed. When I followed the instructions on how to reproduce the problem all went well for me and the translated node appeared on the page as expected.
Comment #30
quietone CreditAttribution: quietone at PreviousNext commentedI tested this on 9.4.x and was not able to reproduce this error. I followed the steps given in the Issue Summary. This was also reported as not not reproducible on Drupal 8.4. in #21.
Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!
Comment #31
quietone CreditAttribution: quietone at PreviousNext commentedAdding tag.