Problem/Motivation
Problem 1:
Create a new content type 'foo' and set following settings:
- default language: Current interface language
- Show language selector
- Enable translation
Save the content type and edit again. The settings are back to default.
Problem 2:
In the settings of content language I marked 'Custom Block' to have custom language settings.
After that I'm creating a new custom block type (admin/structure/block/block-content/types).
I create a new block type with the label 'test', and don't change anything of language settings.
After submitting, i get following fatal error: Fatal error: Call to a member function setDefaultLangcode() on a non-object in .../core/modules/language/language.module on line 218
Proposed resolution
The submit is added to the 'submit' button. But when field ui is enabled, the button is 'save_continue'.
Adding a check if the field ui button is on the form, fixes the problem of the submit function being removed.
As an extra, the bundle is empty in the submit function. This causes the fatal error in problem 2. By making sure the bundle is always loaded through the form object, the correct bundle can be found.
Comment | File | Size | Author |
---|---|---|---|
#10 | translation_add_bundle-2408439-10.patch | 6.39 KB | nils.destoop |
#10 | translation_add_bundle_test-2408439-10.patch | 2.97 KB | nils.destoop |
#7 | translation_add_bundle-2408439-7.patch | 4.12 KB | nils.destoop |
#4 | issue-2408439.png | 128.87 KB | askibinski |
#1 | block_type_translation-2408439-1.patch | 821 bytes | nils.destoop |
Comments
Comment #1
nils.destoop CreditAttribution: nils.destoop commentedThis patch fixes the fatal error by loading the bundle via the form object (option 2). Correct me if this is wrong :)
Comment #2
nils.destoop CreditAttribution: nils.destoop commentedComment #3
larowlanThanks
Comment #4
askibinski CreditAttribution: askibinski commentedThis patch fixed the first fatal error for the scenario as described in the issue topic, but it fails on a second one:
Fatal error: Call to a member function setThirdPartySetting() on a non-object in ../core/modules/content_translation/src/ContentTranslationManager.php on line 61
I figured out this second fatal error is only triggered when you add a block and do not check the "enable translation" checkbox (see screenshot).
Comment #5
nils.destoop CreditAttribution: nils.destoop commentedContent translation was not enabled here. When i enable the content translation, the same error is indeed occurring.
Comment #6
nils.destoop CreditAttribution: nils.destoop commentedSeems there is also a bug with adding a content type. The settings are not saving when adding a content type. That's the reason why this fatal error isn't occurring on that type.
I added a content type 'Language test' with translation enabled, and 'Show language selector' checked. After saving the first time, the settings are gone.
Comment #7
nils.destoop CreditAttribution: nils.destoop commentedThe main problem is being caused by field ui module. He is setting access to FALSE on the normal submit and creates a new submit button. All submit methods added in process are added on the wrong button.
Attached a patch that fixes the problem for both content types as block types. Now I'm gonna check for a test.
Comment #8
askibinski CreditAttribution: askibinski commentedThere are a lot of "language-content, translatable fields" tagged issues, I wonder if this is related to any of those:
https://www.drupal.org/project/issues/search?text=&projects=&assigned=&s...
Comment #9
nils.destoop CreditAttribution: nils.destoop commentedThis one mentioned the same problem #2328161: "Enable Translation" checkbox default non-predictable for new bundles, but only the default state was fixed there. But if you look at the steps, it matches this issue.
Comment #10
nils.destoop CreditAttribution: nils.destoop commentedAttached 2 patches. First patch are updated tests to show the bug (in language module and content translation). 2nd patch is the fix + the updated tests.
Comment #12
rpayanmI closed this #2417893: Call to a member function setDefaultLangcode() on a non-object.
Comment #13
larowlanthanks
Comment #14
alexpottThis issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed f1766f9 and pushed to 8.0.x. Thanks!