Closed (fixed)
Project:
Paragraphs
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Oct 2015 at 18:27 UTC
Updated:
2 May 2016 at 13:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexej_d commentedComment #3
hctomI can confirm this bug. I just tried to add an entity reference field to a paragraphs type that references a Block entity, but it is impossible to add this paragraph due to the above stated errors.
I will also have a look at the code, but perhaps one of the maintainers has an easy fix right out of the box? ;)
Comment #4
farald commentedHey, just confirmed this.
InvalidArgumentException: Invalid translation language (zxx) specified. i Drupal\Core\Entity\ContentEntityBase->addTranslation() (linje 826 i /home/foo/core/lib/Drupal/Core/Entity/ContentEntityBase.php).Comment #5
farald commentedUpdate: Setting the default node language is a confirmed workaround, though I'd love to not having to enable that :)
Comment #6
jeroen.b commented@farald, you can also use this workaround:
You might want to do some extra checks inside the hook to get the correct langcode if you don't want LANGCODE_NOT_SPECIFIED.
Comment #7
ksavoie commentedGetting this same error except on an site that is NOT multilingual.
Content of site was migrated from D7.
With the migration came a content type "Article".
Added a 2 text field Paragraph to this content type.
New "Articles", I can successfully add in Paragraphs with expected behavior.
Existing "Articles" (ones that came over in the migration), I receive this error in console when I press the add Paragraph button.
Comment #8
ksavoie commentedjeroen.b (#6)
I attempted to use your workaround however I am still receiving the error when editing nodes that were migrated from D7. New nodes of the same type have no issue with 'Paragraphs'.
I also tried 'LANGCODE_DEFAULT' as the language type as my site is not multilingual.
Just to verify your workaround is placed in xzy.theme file correct?
Any additional insight to get this module to work greatly appreciated!
Thanks.
Comment #9
jeroen.b commented@ksavoie, no, the code should be placed in a .module file.
HOOK in the function name should be replaced with the module name.
Comment #10
ksavoie commentedjeroen.b #6 works! Thank you!
The only addition I would add for the readers is that in your module make sure to include at the top
so your module has access to the 'Language' class.
Comment #11
LuxianI managed to fix this issue with the following patch. Not sure if it's the right approach. #6 didn't work for me (got the same error).
I was inspired by node module, which adds the source language as a field to add translation form and probably sets it on submit.
Comment #12
LuxianComment #13
ksavoie commentedWell I spoke too soon. #6 didn't fully correct my paragraphs in my application and @Luxian's patch didn't work either.
I have some info that may shed some light.
In my install the majority of content came from a D7 migration. In reviewing different nodes the 'langcode' values are a mix between 'en' and 'und'. The D8 site is not configured as multilingual (Language not installed).
After some tinkering it appears this issue may revolve around this.
I enabled the Language module (with only English) and enabled language selection for content type 'page' (for which I have a Paragraph).
It appears that Paragraph fails when the the nodes langcode does not match Paragraphs default language.
When I change the nodes language to Paragraphs default it works.
b.t.w I removed both #6 and #11 fixes.
To work around the problem in my implementation, I enabled language selection on the Paragraph I created and the node types that have it implemented (/admin/config/regional/content-language) and set both Default Languages to "- Not Specified -" (which is what the majority of my nodes are). On nodes that come up as English I just update to "- Not Specified -" and Paragraphs works.
I hope this info leads to a fix!
Comment #14
miro_dietikerPromoting for attention.
Still, we need test coverage for the issues identified.
Comment #15
berdirSeems like a release blocking bug?
Comment #16
ksavoie commentedIs there anything I can provide that would assist in debug?
Comment #17
therealssj commentedHere is a patch that works for me.
@ksavoie in your comment #13 it works because addTranslations is only called if your target langcode and default langcode are different so when you target to default as mentioned by you the content loads.
Comment #18
therealssj commentedComment #22
webflo commentedThe patch in #11 did not work for me. The paragraph widget assumes that the parent entity is always translatable and tries to derive the paragraph language from its host entity. This does not work with ContentEntityBase. ContentEntityBase does not allow translations for locked languages. I tried to derive the paragraph language from the current language context if the parent entity is not translatable.
Comment #23
webflo commentedThe patch in #11 did not work for me. The paragraph widget assumes that the parent entity is always translatable and tries to derive the paragraph language from its host entity. This does not work with ContentEntityBase. ContentEntityBase does not allow translations for locked languages. I tried to derive the paragraph language from the current language context if the parent entity is not translatable.
We should move the comment to addMoreAccess
Typo. The form ..
Comment #24
therealssj commentedThe patch in #22 fails if we try to add an untranslatable paragraph on a new node.
Now getting the paragraph language from current language if an untranslatable paragraph is added.
Also added test coverage for this.
Comment #28
therealssj commentedForgot to check whether langcode was set.
Comment #29
therealssj commentedComment #30
tduong commentedOpened a "multilingual workflow bugs only meta issue" #2698239: Multilingual workflow bugs for a "general" discussion for these kind of bugs.
Comment #31
miro_dietikerThis needs a recheck after the general multilingual fix.
Comment #32
miro_dietikerduplicate.
Comment #33
johnchqueIt seems it has been already fixed in the Multilingual issue, but just to be sure, added tests taken from @tduong patch. Also tested manually, seems to be working fine now. :')
Comment #34
berdirThis should use the constant instead.
Changing to a normal task and updating title, issue summary should also be updated.
Comment #35
therealssj commentedPatch fix according to #34
Comment #36
therealssj commentedThere we go.
I hope this is good enough :)
Comment #37
tduong commentedGood! Set to needs review for testbot test.
Comment #41
tduong commentedRerolled.
Comment #42
johnchqueThink looks good enough.
Comment #43
miro_dietikerThx, committed. :-)