Problem/Motivation

At the moment of add a menu item from the edit article page, the save process doesn't save the programmed menu, even the name title, description, parent item and weight. saving is not working, i have to do it from the structure button from the edit menu.

#5:
Menu ui binds its submit handler to the 'Save' button:

$form['actions']['submit']['#submit'][] = 'menu_ui_form_node_form_submit';

However, the 'save' button is disabled for users with 'administer nodes' permission in favor of 'Save and publish' / 'Save and keep published' etc. This situation is not tested in MenuNodeTest so that's why all tests are passing.

Proposed resolution

Remaining tasks

User interface changes

API changes

Original report by @Frankencio

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

jibran’s picture

Priority: Normal » Critical

We can't ship with this bug so it is a critical.

webchick’s picture

Issue tags: +Needs tests

Huh. How do we not have tests for this?

tim.plunkett’s picture

Title: Add menu from the editting page doesn`t save the changes » Add menu from the editing page doesn't save the changes
Issue summary: View changes
idebr’s picture

dawehner’s picture

Wow, I'll have a look at it.

idebr’s picture

Menu ui binds its submit handler to the 'Save' button:

$form['actions']['submit']['#submit'][] = 'menu_ui_form_node_form_submit';

However, the 'save' button is disabled for users with 'administer nodes' permission in favor of 'Save and publish' / 'Save and keep published' etc. This situation is not tested in MenuNodeTest so that's why all tests are passing.

Is the proposed resolution to bind the submit handler to all submit buttons or is there a more elegant way?

idebr’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
3.15 KB
3.94 KB

Attached patch binds the submit handler to every submit handler on the node form. I hope there is a more elegant way?

I also updated MenuNodeTest to indicate the problem.

The last submitted patch, 8: 2423153-6.fail_.patch, failed testing.

xjm’s picture

Status: Needs review » Needs work

Thanks @idebr and @Frankencio!

I think in #8, rather than removing existing test coverage and replacing it with the new coverage, we should be adding additional test coverage.

dawehner’s picture

FileSize
2.34 KB

In the meantime I tried to write proper new test coverage, but was not yet able to make it pass.

Honestly I think its quite a WTF, that you have to do it.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.32 KB
3.11 KB
766 bytes

Alright, there was a bug in the test :)

catch’s picture

We have a major issue from two years ago exactly for this problem #1901216: Modules cannot reliably enhance or alter the node form anymore.

dawehner’s picture

idebr’s picture

Assigned: Unassigned » idebr
Status: Needs review » Needs work

@dawehner Thanks for working on the tests. The test-only patch passed the testbot, so I'll have a look if I can make them fail properly.

idebr’s picture

Status: Needs work » Needs review
FileSize
2.41 KB
2.34 KB
3.19 KB

The tests that were supposed to fail still found the menu link that was added by the 'editor' before. I moved the part with the 'admin_user' in front, so the tests assertions fail correctly.

idebr’s picture

Assigned: idebr » Unassigned
dawehner’s picture

The tests that were supposed to fail still found the menu link that was added by the 'editor' before. I moved the part with the 'admin_user' in front, so the tests assertions fail correctly.

Ha, good catch!

The last submitted patch, 16: 2423153-16.fail_.patch, failed testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I like how this patch looks now

  • webchick committed eeb96e9 on 8.0.x
    Issue #2423153 by idebr, dawehner, Frankencio: Add menu from the editing...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Hm, yeah it's definitely unfortunate that we need this sort of logic just because of different button names. I guess #1901216: Modules cannot reliably enhance or alter the node form anymore is the place to talk about fixing that up. The approach looks generic enough though to account for the fact that contrib might add other dropbutton options here, and the test coverage is nice and thorough.

Committed and pushed to 8.0.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.