.../src/Plugin/rest/resource/EntityResource.php | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 0477982..0b63598 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -144,21 +144,21 @@ public function patch(EntityInterface $original_entity, EntityInterface $entity } // Overwrite the received properties. - $langcode_key = $entity->getEntityType()->getKey('langcode'); - $bundle_key = $entity->getEntityType()->getKey('bundle'); + $entity_keys = array_values($entity->getEntityType()->getKeys()); foreach ($entity->_restSubmittedFields as $field_name) { - // \Drupal\serialization\Normalizer\EntityNormalizer::denormalize() needs - // the bundle to be able to denormalize the entity, if the entity type has - // a bundle key. - if ($bundle_key && $field_name === $bundle_key) { - continue; - } - $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. - if ($field_name == $langcode_key && $field->isEmpty()) { - continue; + + // Entity key fields need special treatment. + if (in_array($field_name, $entity_keys)) { + // Unchanged Values for entity keys same don't need access checking. + if ($original_entity->get($field_name)->getValue() === $entity->get($field_name)->getValue()) { + continue; + } + // 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. + else if ($field_name === $entity_keys['langcode'] && $field->isEmpty()) { + continue; + } } if (!$original_entity->get($field_name)->access('edit')) {