Problem/Motivation

- Install with Standard profile in English.
- Turn on the 4 multilingual modules.
- Add Spanish language.
- Make Node translatable (both content types), and User.
- Add an English Article node translated to Spanish, and a Spanish Page node
translated to English.
- Translate User 1 into Spanish

Now go to admin/content. You will see 2 copies of each translation in the table. This is really pretty horrible.

Screen shot of admin/content after following the steps above

The reason, I think, is that there is probably a join between node and user in this view, which multiplies the number of rows because both node and user have 2 entries per item in the field data tables.

Proposed resolution

Fix it so that there is only one copy of each translation in the table. I have no idea how to do this.

Remaining tasks

Make a patch. See #15
Add tests
Review
Commit

User interface changes

TBA - before and after screenshots

API changes

Probably not.

Data model changes

Shouldn't be.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon created an issue. See original summary.

plach’s picture

Ouch, probably we need to ensure the join also has the following condition:

user_field_data.default_langcode = 1.

jhodgdon’s picture

Yeah, that would probably be the thing to do for the admin/content view.

Probably there is no generic fix -- this is going to come up whenever you do a join in views with translations of multiple entities. For instance on this same site I just made some multilingual comments and made a Comment view. There things are also duplicated, because there's an automatic join to Node and nodes are also translated.

In this case I don't think filtering the nodes to user_field_data.default_langcode = 1 would be good. I'd more likely, if I wanted to display Node information, I'd want it to be filtered/displayed to the same language as the comment information in the same row (if available)... unsure... there is not a way currently to make the langcodes match on the join the way you could if you were manually doing the SQL query.

plach’s picture

Is adding a filter for user_field_data.langcode = <current content language> a possible workaround?

jhodgdon’s picture

I do not think that is a good idea, because it is quite likely that user accounts are not fully translated, so in that case you might not have a version of the user that matches the language of the content.

dawehner’s picture

Can someone post the query which is actually executed. I thought we don't join to the user table ever and just load all the entities on all rows which then loads the user entity and renders a link to it ...

jhodgdon’s picture

Here's the query:

SELECT node_field_data.langcode AS node_field_data_langcode, users_field_data_node_field_data.langcode AS users_field_data_node_field_data_langcode, node_field_data.nid AS nid, users_field_data_node_field_data.uid AS users_field_data_node_field_data_uid
FROM 
{node_field_data} node_field_data
INNER JOIN {users_field_data} users_field_data_node_field_data ON node_field_data.uid = users_field_data_node_field_data.uid
WHERE (( (node_field_data.status = 1 OR (node_field_data.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1) ))
ORDER BY node_field_data.changed DESC
jhodgdon’s picture

FileSize
15.4 KB

Looks like the user table is exposed probably due to the "Published status or admin user" filter. Here's the filter list:
filters from admin/content view

Lendude’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
2.91 KB
40.11 KB

Currently the users_field_data table is joined to show the author name. To do that, a relationship was added to the view which probably causes the duplication.

This patch substitutes the user:name for the 'authored by' field and then sets the formatter to Author. No relationship needed that way (no idea if this has any other impact though). In theory, this should fix the problem.

The query looks like this when using this config

Status: Needs review » Needs work

The last submitted patch, 9: content_duplicate_rows-2582535-9.patch, failed testing.

Lendude’s picture

Status: Needs work » Needs review
FileSize
548 bytes
2.87 KB
+++ b/core/modules/node/config/optional/views.view.content.yml
@@ -239,25 +239,71 @@ display:
+          settings:
+            link: 0

ok so apparently this export with config manager doesn't pass testing. Removed the offending bit and passes locally now.

jhodgdon’s picture

Issue tags: +Needs manual testing

Hm. Do all of the existing sorts/filters/links/etc. that were on admin/content still work with this change? Probably needs manual side-by-side testing.

And this fix does not address the underlying real problem, which is that if you make a view of nodes with a relationship to the author (for whatever valid reason that you might have), and both users and nodes are translated, you will end up with duplicate rows. All this patch does is make it so that the default admin/content view doesn't use a user relationship.

martins.kajins’s picture

This issue maybe could be solved, when view uses language filter according to current interface language. If language is en it will show only en versions for articles, and if it is spanish language it will show spanish nodes.

I made language filter not exposed. I think this is way how admin/content page worked in D7

Status: Needs review » Needs work

The last submitted patch, 13: core-use-current-interface-language-2582535-13.patch, failed testing.

Lendude’s picture

@martins.kajins that would only remove the node with the non-current language. You would still get a duplicate row for the translated user and the current language node.

Both the node_field_data and user_field_data contain language settings so if you join these two tables, you get duplicate rows (well not exactly duplicate, one for each language combination), that's just the way joins work.

So the only way to prevent duplicate rows is to not do that join (or not store language settings in those tables...), or add more filters to reduce the duplicates. But less joins sounds better then adding more filters that are pointless by default.

jhodgdon’s picture

Well, this issue is about how rows in views multiply if you have a join.

The other issue is about a single-table view.

Yes, they're kind of related, but I don't think they're the same issue or that if we solve the other one, this one will also be solved.

xjm’s picture

Issue tags: +Triaged core major

The core committers and Views maintainers (alexpott, xjm, effulgentsia, tim.plunkett, and dawehner) agreed that this is a major issue. It's a prominent and confusing bug on one of core's most important administration forms for multilingual sites. The issue is not critical because the view is still usable and the actual data are not affected.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

szeidler’s picture

I also ran into the issue with a site, that depends on translated users. I tested the patch in #11 and it solves the problem of duplicating the rows, as it is removing the JOIN to the user_field_data table.

Do all of the existing sorts/filters/links/etc. that were on admin/content still work with this change? Probably needs manual side-by-side testing

Yes, unfortunately it introduces a regression. The content "Authored by" field is based on the uid and so you'll get confusing results, when sorting by that column. The user would expect it to be sorted by the username, but it's actually by uid:
ORDER BY node_field_data.uid ASC

That might have been one of the reasons for having introduced the relationship.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Jorgillo’s picture

Hello there, we've having the same issue with an editor with enabled translations, anytime she creates an article it appears duplicated in the content table.

This is kind a benign bug so we don't know which is the best approach, should we apply the patch exposing the incompatibilty @szeidler commented or is this bug expected to be solved with the 8.5 update?

Have we got any info in the status of this issue?

Thanks in advance :)

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

MiquelFuster’s picture

HI, I found a solution in this post https://www.danbp.org/p/en/node/123

It works for me

phannphong’s picture

Hi MiquelFuster,
Thanks for your link to temporary solve this problem. I confirm that the second point can fix this issue.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

vitch’s picture

#2 said user_field_data.default_langcode = 1
I am guessing it means add a filter criteria (author) User: Default translation (= True)
This solved it in my case

kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
kkalashnikov’s picture

Hello,

If I got the issue right can easily be managed by adding the filter Content: Default Translation(=True) in the content listing page view (admin/structure/views/view/content) and the default translated content will show.

For example, if default translation for particular content is in English (Other translation also available) then it will show only English content.

Thanks,
Kunal Gautam

kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned
Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

That solution has already been discussed above, and it does not address the underlying problem -- you might want to make a view that shows different translations.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

meder’s picture

#30 worked. Thanks.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Confirmed still an issue in 9.5

ravi.shankar’s picture

Added reroll of patch #13 on Drupal 9.4.x. still needs work for comment #34.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Needs work » Active
Issue tags: +Bug Smash Initiative

@ravi.shankar, thanks for rerolling.

I don't that #13 should have been rerolled. In #15, a maintainer explains why that patch is not the desired approach. I don't understand why #34 needs to be addressed, in that comment @jhodgdon was explaining why the suggestion in the previous comment was already discussed and is not the solution.

I would think that patch needs to follow the direction in #15. And since there isn't a patch for that I am setting this to active.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

HeikkiY’s picture

I can also confirm that #30 solves the issue. We had a confusing list of duplicated content in the admin/content listing when we added an exposed filter for the Author to be able to find the content for certain user more easily. The problematic results were done by a translated user profile.