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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler created an issue. See original summary.

miro_dietiker’s picture

Reads 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?

tstoeckler’s picture

No, I don't think so. We *could* test the langcode key thing, but I'm not sure if that's of much value TBH.

miro_dietiker’s picture

Status: Needs review » Fixed

Committed. Happy to see this fixed and use the real entity keys.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.