core/modules/rest/src/Plugin/rest/resource/EntityResource.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 6f18e7d..4b6febc 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -230,6 +230,12 @@ public function patch(EntityInterface $original_entity, EntityInterface $entity // Overwrite the received fields. foreach ($entity->_restSubmittedFields as $field_name) { $field = $entity->get($field_name); + // It is not possible to set the language to NULL as it is automatically + // re-initialized. As it must not be empty, skip it if it is. + // @todo Remove in https://www.drupal.org/project/drupal/issues/2933408. + if ($entity->getEntityType()->hasKey('langcode') && $field_name === $entity->getEntityType()->getKey('langcode') && $field->isEmpty()) { + continue; + } if ($this->checkPatchFieldAccess($original_entity->get($field_name), $field)) { $original_entity->set($field_name, $field->getValue()); }