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.
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.
Comment | File | Size | Author |
---|---|---|---|
#41 | reroll_diff_13-41.txt | 1.29 KB | ravi.shankar |
#41 | 2582535-41.patch | 939 bytes | ravi.shankar |
#32 | Screenshot 2020-04-30 at 3.47.41 PM.png | 61.57 KB | kkalashnikov |
#13 | core-use-current-interface-language-2582535-13.patch | 1.08 KB | martins.kajins |
#11 | content_duplicate_rows-2582535-11.patch | 2.87 KB | Lendude |
Comments
Comment #2
plachOuch, probably we need to ensure the join also has the following condition:
user_field_data.default_langcode = 1
.Comment #3
jhodgdonYeah, 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.
Comment #4
plachIs adding a filter for
user_field_data.langcode = <current content language>
a possible workaround?Comment #5
jhodgdonI 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.
Comment #6
dawehnerCan 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 ...
Comment #7
jhodgdonHere's the query:
Comment #8
jhodgdonLooks like the user table is exposed probably due to the "Published status or admin user" filter. Here's the filter list:
Comment #9
LendudeCurrently 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
Comment #11
Lendudeok so apparently this export with config manager doesn't pass testing. Removed the offending bit and passes locally now.
Comment #12
jhodgdonHm. 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.
Comment #13
martins.kajins CreditAttribution: martins.kajins at Wunder commentedThis 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
Comment #15
Lendude@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.
Comment #16
alexpottIs this a duplicate of #2473989: Lack of dynamic language field / filter makes shipping core views hard to be both compatible with mono and multilingual? At the very least it seems related.
Comment #17
jhodgdonWell, 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.
Comment #18
xjmThe 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.
Comment #22
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedI 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.
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.
Comment #25
Jorgillo CreditAttribution: Jorgillo commentedHello 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 :)
Comment #27
MiquelFuster CreditAttribution: MiquelFuster commentedHI, I found a solution in this post https://www.danbp.org/p/en/node/123
It works for me
Comment #28
phannphong CreditAttribution: phannphong commentedHi MiquelFuster,
Thanks for your link to temporary solve this problem. I confirm that the second point can fix this issue.
Comment #30
vitch CreditAttribution: vitch commented#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
Comment #31
kkalashnikov CreditAttribution: kkalashnikov commentedComment #32
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company commentedHello,
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
Comment #33
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company commentedComment #34
jhodgdonThat 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.
Comment #36
meder CreditAttribution: meder commented#30 worked. Thanks.
Comment #40
smustgrave CreditAttribution: smustgrave at Mobomo commentedConfirmed still an issue in 9.5
Comment #41
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedAdded reroll of patch #13 on Drupal 9.4.x. still needs work for comment #34.
Comment #43
quietone CreditAttribution: quietone at PreviousNext commented@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.
Comment #45
HeikkiY CreditAttribution: HeikkiY commentedI 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.