From d0ac10561d8a5790e5658bc2456de09819635fc4 Mon Sep 17 00:00:00 2001 From: xjm Date: Sun, 26 Apr 2015 18:35:53 -0500 Subject: [PATCH] Issue #2475805 by tstoeckler, googletorp, webwarrior: menu_ui_form_node_form_submit() is called when the Preview button is pressed which fatals --- core/modules/menu_ui/menu_ui.module | 2 +- core/modules/menu_ui/src/Tests/MenuNodeTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 95c9e3e81f0..3234e769766 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -334,7 +334,7 @@ function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { ); foreach (array_keys($form['actions']) as $action) { - if (isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') { + if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') { $form['actions'][$action]['#submit'][] = 'menu_ui_form_node_form_submit'; } } diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php index 8e14d412ac2..6b1a9a4bf80 100644 --- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php +++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php @@ -91,6 +91,14 @@ class MenuNodeTest extends WebTestBase { $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %name has been updated.', array('%name' => 'Basic page'))); + // Test that we can preview a node that will create a menu item. + $edit = array( + 'title[0][value]' => $node_title, + 'menu[enabled]' => 1, + 'menu[title]' => 'Test preview', + ); + $this->drupalPostForm('node/add/page', $edit, t('Preview')); + // Create a node. $node_title = $this->randomMachineName(); $edit = array(