There is a problem with the Views UI when used with multilingual Drupal sites. If a view is accessed in another language then the default language the Views UI will load the translated strings if available. So far so good but when hitting the Save button those translated strings will overwrite the original strings. Thus the view in default langue now contains translated strings from the translated language.
Steps to reproduce:
1. Set up a view in a view in a multilingual Drupal, in my example I will use German (de) as default and English (en) as additional language.
2. Create a view in default language and translate a few strings into an additional language and save. E.g. the title of the View.
3. Open the View UI in the additional language, in our case English. e.g. http://[drupal_root]/en/admin/structure/views/view/[view_name]/
4. Note that views UI opens the view with the Title translated and save the view.
5. Open the view in it's default language (e.g. http://[drupal_root]/de/admin/structure/views/view/[view_name]/) and note that the original Title has been overridden.
The question arises how Views UI should handle multilingual content. Should it remember that strings are translated and save those correctly or should it always load the original strings from the beginning?
A similar situation would be the translation of the Title Label of a Content Type. In the content type UI Drupal will always load the Title Label in the content types original language no matter what language you access the UI in. Thus anything related to translation are keep separately over at translations only.
Suggested resolution:
1. Remove the translation of strings in the Views UI.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | views-ui-converter-2602268-36-interdiff.txt | 1.33 KB | berdir |
| #36 | views-ui-converter-2602268-36.patch | 5.09 KB | berdir |
| #25 | views-ui-converter-2602268-24-test-only.patch | 2.31 KB | berdir |
| #24 | views-ui-converter-2602268-24-interdiff.txt | 1.23 KB | berdir |
| #24 | views-ui-converter-2602268-24.patch | 5.03 KB | berdir |
Comments
Comment #2
hauruck commentedComment #3
hauruck commentedComment #4
hauruck commentedComment #5
webflo commentedComment #6
webflo commentedComment #7
gábor hojtsyDoes this apply to other things than views? Menus, content types, field settings? I would suspect so.
Comment #8
gábor hojtsyComment #9
hauruck commentedContent type, Field Settings & Menus: Strings will always load into the UI in default language no matter wheat language the UI is loaded in, thus not having problems with overwriting.
Comment #10
hauruck commentedComment #11
gábor hojtsyAdmin pages are supposed to load the entity in its original language without translations, they should let you edit that and save that. It is not supposed to load translated values and it is not supposed to let you edit them on the original UI (unless the original config itself is translated of course). The behavior should be the same across fields, content types, input formats, menus, views, whatever, it should not be different.
Comment #12
xjmThe core committers and Views maintainers (alexpott, xjm, effulgentsia, tim.plunkett, and dawehner) agreed that this actually is potentially a critical issue, because it causes data loss. Promoting to critical for that reason. We should test and confirm the bug still exists as described.
Comment #13
dawehnerSo I'm wondering what is the mechanism that config entities aren't translated on admin forms by default?
Comment #14
catch@dawehner that's implemented in ConfigFormBaseTrait
Comment #15
gábor hojtsyAlso, config entities are upcast without translations on admin routes by default, see AdminPathConfigEntityConverter, which should ensure you get the original values for editing.
Comment #16
tim.plunkettI'm guessing \Drupal\views_ui\ParamConverter\ViewUIConverter and \Drupal\Core\ParamConverter\AdminPathConfigEntityConverter are incompatible with each other.
Comment #17
gábor hojtsyYeah looks like the view converter is higher priority.
From the docs on AdminPathConfigEntityConverter:
So indeed Views takes over the admin converter. Should it sit between the two? :)
Comment #18
gábor hojtsyDiscussed with @dawehner, he says we should look at inheriting the views converter from the admin converter. Looking at this, it does not seem trivial, especially given it comes with API changes to how the views converter is instantiated (if we consider that an API that is).
Comment #19
berdirAccording to #2550249: [meta] Document @internal APIs both explicitly in phpdoc and implicitly in d.o documentation, we don't unless it's a base class, which I think this isn't.
But, it fails pretty hard if you do, since this is instantiated on every request. I added a workaround for that by making the new arguments optional and get them from the container if they're missing. Then the site continues to work after applying the patch.
We could add a @todo to remove it again and make them required later on. (not sure if later is 8.1.x or 9.x)
Still needs tests.
Comment #20
gábor hojtsyI don't think this patch solves the problem yet? It does not change the applies() method or the conversion itself?
Comment #21
maxocub commentedI'm trying to write a test but I can't reproduce the bug with a test. I can easily reproduce it manually, but not with a test. I first save a translation for the label of a view, then I visit the edit page in the second language, but the label is not displayed translated. Does someone knows why? Did I forget something in the test?
Comment #22
berdir@maxocub: You seem to assert for the wrong behavior now in your test? You should write it so that it should pass when being correct. There might be a problem in how the URL is built, I'll check. You should also upload a patch as .patch, not .txt, also if it doesn't work yet.
@Gabor: I haven't tried it yet, but IMHO, it should just work. All the relevant logic is in the parent, the actual code is just about getting it from tempstore instead. But if we ensure that we get the default translation, that should continue to work in the same way.
Comment #23
maxocub commented@Berdir: Yes, I know I'm not asserting for the right thing and that a .txt will not trigger the testbot, this is just a work in progress, I uploaded it just to show where I was going.
I'm trying to load the edit page in the second language to be able to save the view and check if the translated string overrides the original value.
Right now, the label is not translated on the edit page (That's what I'm trying to show with the last assert) so I can't test if it overrides the orignal one.
You might be right with how the URL is built, but I can't find why.
Comment #24
berdirManually tested now, my patch does seem to work.
The test also seems to work for me, more or less. The asserts were a bit confusing because it used assertLink() but the page title isn't a link.
I changed it slightly to use assertTitle() with the full, explicit title, now it fails/passes as expected. Interdiff is against the two patches combined.
Comment #25
berdirForgot the test-only patch.
Comment #26
tim.plunkettIs this really something we do now? :(
Comment #27
berdirI think it is worth doing. It doesn't hurt unit testing (which we don't have anyway for that class) in any way and avoids ugly exceptions when anyone access the site while updating. The class is instantiated on every request, not just in the views backend, then I could totally live with errors.
Should help to get it into a patch release.
Comment #29
tim.plunkettCan we get an @todo to clean it up eventually? Or better yet, a separate 8.1.x patch without that, assuming it goes into 8.0.x like this?
Comment #30
catchAn 8.1.x issue to clean this up would be good. But definitely better to have a temporary ugly hack than an ugly fatal error on every request after a patch update.
Only CNW 'cos the bot liked the test-only patch. Moving back to CNR but for me I can't see anything wrong here, will let someone else RTBC it if they agree.
Comment #31
catchOne issue with an 8.1.x issue is that if someone upgrades direct from 8.0.3 or whatever they'd still get the error, but that should probably be explicitly unsupported for reasons like this.
Comment #32
gábor hojtsy@Berdir: thanks for the explanation, I did not check how do they interoperate properly.
@catch: so looks like we should have a @todo (if the policy does not yet comply with the assumption that it should not be supported to update from earlier patch releases to a minor) or a 8.1 patch if the policy is already that and we are fine with a fatal there.
I think either a @todo or a separate 8.1 patch is needed for this to be RTBC? I assume it is not OK to fix this in 8.0.x and not in 8.1.x at once.
Comment #33
catchI'd go for a new issue for 8.1.x changes, whether it has an associated @todo or not I don't mind too much - there's always git blame pointing to this issue pointing to that issue.
Also if the 8.1.x patch didn't happen but got into 8.2.x instead, that'd solve the 8.1.0 upgrade path question I had.
Comment #34
berdirOk, then lets do exactly that? A @todo and follow-up for *8.2.x* to remove that again?
Comment #35
dawehnerLet's provide a better testclass name, this one isn't really clear. What about using
TranslatedViewTest?Comment #36
berdirChanged the class name, added the todo and opened #2674328: Remove BC code in ViewUIConverter
Comment #37
gábor hojtsyAmazing, thanks all!
Comment #38
dawehnerNice!
Comment #39
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!
Comment #42
gábor hojtsyThanks a lot! Woot :)