Both InlineParagraphsWidget::formElement()
and ::massageFormValues()
try to compare the language code of the paragraph entity with another language code (the one in the form state, to be precise).
They both do it like this:
$paragraphs_entity->get('langcode') != $langcode
The problem is that the left hand side returns a FieldItemList
object, so that will never be true. It seems fairly clear that
$paragraphs_entity->get('langcode')->value != $langcode
is meant instead.
While I'm at it, I'm also fixing the hard-coding of the langcode
key.
Let's see how the testbot likes this.
FULL DISCLAIMER: While I found this while investigating #2675010: Cloned entity will point to the same field objects if the clone was created after an entity translation has been initialized, this does not actually relate to that directly.
Comment | File | Size | Author |
---|---|---|---|
paragraph-langcode.patch | 2.22 KB | tstoeckler | |
Comments
Comment #2
miro_dietikerReads pretty fine, great finding. :-)
From reading the code, it seems this bug just triggered a set of the langcode that was already at that value. So it didn't result in any real harm or effect at all.
Or do you see any other potential bug that possibly need additional test coverage?
Comment #3
tstoecklerNo, I don't think so. We *could* test the langcode key thing, but I'm not sure if that's of much value TBH.
Comment #5
miro_dietikerCommitted. Happy to see this fixed and use the real entity keys.