Steps to reproduce:
- Set up a site with Entity translation enabled for English and (let's say) French.
- Create a new English node that has translations enabled, and set it's title to some kind of value. Ensure there is no French translation for this node.
- Edit the node and set its language from English to French and save.
Expected results:
Node title remains the same.
Actual results:
Node title is set to an empty value since $node->title_field['fr'] is empty and title_field_sync_get() does not prevent this from happening.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 1811116-22.patch | 939 bytes | gaurav.kapoor |
| #20 | title-title_set_to_empty-1811116-20.patch | 1.26 KB | michel.settembrino |
| #18 | title-title_set_to_empty-1811116-18.patch | 1.29 KB | michel.settembrino |
| #16 | title-title_set_to_empty-1811116-16.patch | 930 bytes | webwarrior |
| #8 | drupal-null_ fallback-1811116-8.patch | 4.97 KB | plach |
Comments
Comment #1
dave reidPatch attached for review.
Comment #2
plachI'm not sure this is the right fix. This way we would also prevent any legal empty value from being synced. Taxonomy term descriptions can actually be empty.
Comment #3
dave reidWell it's a major problem with titles which are required, but I forgot this is also used for other things like descriptions.
Comment #4
plachYes, it's a major issue. I think we should find a way to detect the language change and perform the sync with the correct langcode.
Comment #5
plachPer #4.
Comment #6
axe312 commentedThis problem also causes the nodes to be displayed with a blank title in /admin/content and some autocomplete fields.
Workaround:
Reopen the node and save it again. Now the titles will be displayed correctly.
The language change should be easily detectable in the hook_node_presave() (or hook_entity_presave()).
For example in the hook_node_presave, there is a copy of the old node version ($node->orginal). You can just compare the language value of the original node object with the new one to detect the language change.
Comment #7
jpsalter commentedHere is our quick workaround. Not sure where `title_original` is coming from. But, it was on our node object and it works:
Comment #8
plachI stumbled upon this while working on the integration between Title, ET and Inline Entity Forms (ouch). From my debugging it seems that this might be a core issue after all. Can you try the attached patch and check whether it fixes things for you?
Comment #10
plachComment #11
ezra-g commented#8: drupal-null_ fallback-1811116-8.patch queued for re-testing.
Comment #13
ezra-g commentedI believe this is actually a duplicate of #1086454: DATA-LOSS: Changing the Language of a node via language assignment deletes the content on the edit page. Marking "postponed" so others here can help test.
Comment #14
ezra-g commentedCorrection: The core issue is, #1885588: Node Body becomes blank under the Edit tab after changing the node language from Language neutral to any specific language, which appears to be a marked as a duplicate of #1086454: DATA-LOSS: Changing the Language of a node via language assignment deletes the content on the edit page. More investigation is required here.
Comment #15
plachCan you please explain how #1885588: Node Body becomes blank under the Edit tab after changing the node language from Language neutral to any specific language is related to this issue?
Comment #16
webwarrior commentedPossible solution?
Comment #17
kristiaanvandeneyndeNope, breaks synchronization of the page title.
Edit:
To clarify, all of the sudden our node (and other entity) pages would only show the title in the original language.
This is due to the fact that the original default of NULL gets overwritten because the entity indeed has a language property. This causes the Title module to sync the title in the original language, where it used to fall back to field_valid_language() and thus correctly return the content language.
Comment #18
michel.settembrino commentedI had the same issue when I was editing webform components.
The patch I wrote (inspired by patch from #16) solved my issue.
I don't know if this is also a solution for the case described here.
Comment #19
joachim commentedPatch #18 needs a reroll, as it's not been rolled from the right folder.
Comment #20
michel.settembrino commentedPatch rerolled.
Comment #21
joachim commentedInline comments should be formatted with // rather than /* */.
Also, comments do not need to record historical changes to the code - they describe the code as it is now. Say what the code is doing, and describe anything that's a workaround for a problem, so for example: 'When the node is not being edited, the language must be set to yadayada to prevent yadayada.'
Comment #22
gaurav.kapoor commentedRe rolled and changed according to suggestions in #21.
Comment #23
pifagor commentedComment #25
pifagor commentedComment #27
mhowe91 commentedThis patch broke the translation of titles on the webform confirmation page. A form submitted in French that redirects to the confirmation page, would display the title/ breadcrumb in English, even though the title was properly translated. Issue created - #3179509: Title is not translated on webform confirmation page
Comment #28
joseph.olstadplease see #3179509-4: Title is not translated on webform confirmation page
Comment #29
joseph.olstadactually, see this instead:
#3100045: Workbench moderation french drafts show wrong title