diff --git a/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php b/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php index a27cbe967f..8a2f07779c 100644 --- a/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php +++ b/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php @@ -30,7 +30,7 @@ public function validate($entity, Constraint $constraint) { $violation_path = 'menu'; } // Handle the case when the menu link is deleted in a forward revision. - elseif (empty($values['enabled'] && $values['entity_id'])) { + elseif ($defaults['entity_id'] && empty($values['enabled'] && $values['entity_id'])) { $violation_path = 'menu'; } // Handle all the other menu link changes in a forward revision. @@ -40,10 +40,10 @@ public function validate($entity, Constraint $constraint) { elseif (($values['description'] != $defaults['description'])) { $violation_path = 'menu.description'; } - elseif (($values['menu_name'] != $defaults['menu_name'])) { + elseif ($defaults['entity_id'] && ($values['menu_name'] != $defaults['menu_name'])) { $violation_path = 'menu.menu_parent'; } - elseif (($values['parent'] != $defaults['parent'])) { + elseif (isset($values['parent']) && ($values['parent'] != $defaults['parent'])) { $violation_path = 'menu.menu_parent'; } elseif (($values['weight'] != $defaults['weight'])) { diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php index 85eb6adc93..c7a51db9cd 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php @@ -58,6 +58,14 @@ public function testMenuUiWithForwardRevisions() { // Create a node. $node = $this->drupalCreateNode(); + // Publish the node with no changes. + $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and Publish')); + $this->assertSession()->responseContains(t('Page %label has been updated.', ['%label' => $node->toLink($node->label())->toString()])); + + // Create a forward revision with no changes. + $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and Create New Draft')); + $this->assertSession()->responseContains(t('Page %label has been updated.', ['%label' => $node->toLink($node->label())->toString()])); + // Add a menu link and save a new default (published) revision. $edit = [ 'menu[enabled]' => 1,