Skip to content
Snippets Groups Projects

Issue#3486604:node-edit-form-resave-issue.

Open Atul Ghate requested to merge issue/drupal-3486604:3486604-node-edit-form into 11.x
1 unresolved thread

Closes #3486604

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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]);
  • Maintainer

    This could probably use ::hasAffectingChanges() instead?

  • 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
Please register or sign in to reply
Loading