From abfdc5ec24f301a27d5ead687e3f450efdca8730 Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Wed, 27 May 2015 22:53:19 -0700 Subject: [PATCH] Issue #2495407 by jhedstrom, Noe_, cilefen: Regression: Editing a node with a disabled menu link re-enables that menu link --- core/modules/menu_ui/menu_ui.module | 2 +- core/modules/menu_ui/src/Tests/MenuNodeTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index bad8d9f9fed1..c67dbeaaf8fb 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -146,8 +146,8 @@ function _menu_ui_node_save(NodeInterface $node, array $values) { 'link' => ['uri' => 'entity:node/' . $node->id()], 'langcode' => $node->getUntranslated()->language()->getId(), )); + $entity->enabled->value = 1; } - $entity->enabled->value = 1; $entity->title->value = trim($values['title']); $entity->description->value = trim($values['description']); $entity->menu_name->value = $values['menu_name']; diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php index 0f0d1689efee..2647bc890629 100644 --- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php +++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php @@ -171,6 +171,16 @@ function testMenuNodeFormWidget() { $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldById('edit-menu-weight', 17, 'Menu weight correct in edit form'); + // Disable the menu link, then edit the node--the link should stay disabled. + $link_id = menu_ui_get_menu_link_defaults($node)['entity_id']; + /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $link */ + $link = MenuLinkContent::load($link_id); + $link->set('enabled', FALSE); + $link->save(); + $this->drupalPostForm($node->urlInfo('edit-form'), $edit, t('Save')); + $link = MenuLinkContent::load($link_id); + $this->assertFalse($link->isEnabled(), 'Saving a node with a disabled menu link keeps the menu link disabled.'); + // Edit the node and remove the menu link. $edit = array( 'menu[enabled]' => FALSE, -- GitLab