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 7e47c85..b43b565 100644 --- a/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php +++ b/core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php @@ -26,7 +26,7 @@ public function validate($entity, Constraint $constraint) { } // Handle the case when a menu link is added to a forward revision. - if ($defaults['entity_id'] != $values['entity_id']) { + if (!$defaults['entity_id'] && $values['enabled']) { $violation_path = 'menu'; } // Handle the case when the menu link is deleted in a forward revision. diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php index c7a51db..a593b36 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiContentModerationTest.php @@ -134,6 +134,21 @@ public function testMenuUiWithForwardRevisions() { // Check that the menu settings were not applied. $this->assertSession()->pageTextNotContains('You can only change the menu settings for the published version of this content.'); $this->assertSession()->linkExists('Test menu link'); + + // 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()])); + + // Add a menu link and save and create a new non-default (draft) revision. + $edit = [ + 'menu[enabled]' => 1, + 'menu[title]' => 'Test menu link', + ]; + $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and Create New Draft')); + $this->assertSession()->pageTextContains('You can only change the menu settings for the published version of this content.'); } }