Issue#3486604:node-edit-form-resave-issue.
1 unresolved thread
1 unresolved thread
Closes #3486604
Merge request reports
Activity
108 108 $entity = $entity->getUntranslated(); 109 109 $entity->set($entity->getEntityType()->getKey('langcode'), $node->language()->getId()); 110 110 } 111 // Check if the value has changed before updating. 112 $isChanged = FALSE; 113 foreach (['title', 'description', 'menu_name', 'parent'] as $field) { 114 if ($entity->$field->value !== trim($values[$field])) { 115 $entity->$field->value = trim($values[$field]); Along these lines, I think checking for changes can be done overall in a smaller diff: After loading the existing menu link content
$entity = MenuLinkContent::load($values['entity_id']);
, clone the$entity
object and set it as the original:$entity->original = clone $entity;
Then at the bottom of the function, wrap the entity save code in a conditional to check whether the entity has translation changes before saving:
if ($entity->hasTranslationChanges()) { $entity->isDefaultRevision($node->isDefaultRevision()); $entity->save(); }
Please register or sign in to reply