Problem/Motivation

Menu drag and drop can exceed either suhoson max_* or PHP's own max_input_vars, resulting in changes from the form silently disappearing.

Since there is no PHP error, there's no way for the user to know that their form submission has been lost except for checking the form again.

Tabledrag has hidden select lists for weight, it's possible this is hitting limits if a lot of them are shown on the page.

Proposed resolution

The select lists only show for users without JavaScript, or if 'show weight's is clicked, should we change them to textfields instead?

Remaining tasks

User interface changes

API changes

Data model changes

So I am a long time user of D6 and recently started to create a new website using D8. I'm completely frustrated by the menu system as what should be a fairly straightforward process, is not. Either I am missing something or there is a critical bug out there. All I am trying to do is create a submenu item in the Primary Menu.

I have the default "home" menu item listed there and I have 2 other menu items called "My Items" and "My Coordinations" which are created via Views to the view page.

I would like to simply add a menu item called "Add Item" which is linked to /node/add/item.

I have created this menu item manually through the "add link" button on http://sitename.com/admin/structure/menu/manage/main.

It appears fine and works. But once I move the menu item by dragging it to become the submenu item of "My Items" and click the save button. The page refreshes with the menu item back on the main level with all menus and now (disabled). WHY!?!?!?

Also, another issue is now that it's disabled, if I try to click the enable checkbox and hit save from the main (primary) menu edit page. It will NOT enable after save. It will just go back to being disabled (i.e. NO CHANGE). I have found that I need to actually click the edit button for that menu item and then on the menu item's edit page, I can click the checkbox next to "Enabled" with sub text "A flag for whether the link should be enabled in menus or hidden.". Then after I click the save button on that page, it will go back to the main menu edit page and show it now enabled. Why do I need to drill into it to enable it, why does the enable checkbox on the main edit page of the Main (Primary) menu not work!?!?

Then again, if I now drag it under the "My Items" menu again to make it a submenu item (i.e. it shows as indented under My Items), and click save, it will again move it out from under My Items and disable it again.

What the heck is going on?!!?

CommentFileSizeAuthor
#7 2.png54.97 KBdksdev01
#7 1.png68.16 KBdksdev01
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drupalfan81 created an issue. See original summary.

cilefen’s picture

Priority: Critical » Major
Issue tags: -submenu disabled

By definition, this is not critical because there is a workaround. I removed extraneous tags.

drupalfan81’s picture

@Cilefen, what is the work around? I cannot enable these menu items as subitems of the menu. It's not possible. Wouldn't that imply critical?

I have created a screencast to show the behavior in action. Please advise what I can do to work around this. So far, not very impressed by the latest version of D8, since it appears unable to handle a very simple feature, such as submenu items.

Please have a look at the video and tell me if I am just doing something wrong. If not, this is a pretty critical bug that should be addressed.

http://www.screencast.com/t/aMOovPTfSv

Thanks!

cilefen’s picture

Apologies if I read the summary wrong. My interpretation was that you were able to enable the items by editing directly, but I think you are reporting a related (maybe one and the same) UI issue. I am tragically bad at reading long paragraphs.

There are some similar issues like #2711369: D8: The positioning of menu items within menus is unstable.

It would help the maintainers if you could please add to the issue summary the steps to reproduce in an ordered list. Thank you!

cilefen’s picture

Also:

  • Any contrib modules installed?
  • Anything logged in watchdog or the PHP error log?
drupalfan81’s picture

@Cilefen,

No worries. No noticeable errors and this is a pretty much out of the box install of Drupal. I have only added the Colorbox and Token modules to this site. I'm just getting started with this site and hence setting up the menus. So a bit shocked I am running into bugs at this point, especially a bug like this. I would assume something like this wouldn't really be production ready. Anyway, hoping someone comes up with a fix for it.

As for the steps to reproduce it, they can see the screencast video I recorded showing it happen.

Thanks!

dksdev01’s picture

FileSize
68.16 KB
54.97 KB

Looks like this is core bug.. I have experienced too..

I tried with fresh install without any contrib module.. and same error occurred.

When you tries to change menu order .. it disabled all other menu items.

dksdev01’s picture

I tried same thing on localhost and it worked..

gabriele.dorigo’s picture

I experienced the same problem.
Creating a new content, then a menu item for that, on saving menu changes, the menu link is set to disabled.
Creating a new content and checking the option for automatically create a new menu item for the content in the main manu, the menu link is created and automatically set to enabled. So it's visible on the menu.

But entering the main menu to manage it, on save, the link is set to disabled again.

danjng’s picture

Seeing the same issue on 8.1.9. How has it not been resolved yet? Is there some sort of complicated reasoning behind this? It seems like this is a pretty core capability (to be able to drag and reorder AND SAVE) when it comes to rearranging menu items. It's just a pain to keep modifying weights just to 'squeeze a few objects between others'.

Any tips on how to most effectively do that are welcome.

danjng’s picture

Steps to reproduce error:
1- Create new menu item
2- Save new menu item
3- At Edit Menu screen, click on Save button (with or without making any changes)
4- All items will be disabled

danjng’s picture

Version: 8.1.2 » 8.1.9
danjng’s picture

ealia’s picture

I experienced the same problem in my host but in my localhost it work well.

esolitos’s picture

I tested the steps described in #11 and the described behaviour does not happen in on 8.3.x nor does in in 8.2.x.

zenphp’s picture

Currently experiencing this on 8.2.1.

Modules installed:

- admin toolbar
- auto_entityqueue
- config_update
- ctools
- entityqueue
- features
- flexslider
- libraries
- pathauto
- superfish
- token

Steps:
1. Add new page content type
2. Check "provide a menu link" option box
3. Save page

At this point the page is saved and shows up in the menu

1. Go to Structure -> Menus
2. Edit the menu <-- New items show up as enabled here
3. Uncheck enabled box for HOME menu item to disable
4. Click save <- At this point all menu items now show as disabled.
5. Check boxes to enable all menu items
6. Click save <-- At this point the page reloads showing all items STILL disabled

Oddly enough the top level menu items are still showing in the menu even though they are marked in the menu management as disabled.

Watchdog output from my drupal install while adding content and updating the menu:
75 11/Oct 10:00 notice content hub_page: added Hub 1.
76 11/Oct 10:00 notice content hub_page: added Hub 2.
77 11/Oct 10:01 notice content hub_page: added Hub 3.
78 11/Oct 10:01 notice content hub_page: added Hub 4.
79 11/Oct 10:01 notice content hub_page: updated Hub 2.
80 11/Oct 10:02 notice menu Menu Main navigation has been updated.
81 11/Oct 10:05 notice menu Menu Main navigation has been updated.
82 11/Oct 10:07 notice menu Menu Main navigation has been updated.

zenphp’s picture

Version: 8.1.9 » 8.2.1
MarcoDeJong’s picture

This should be critical as this issue cause loss/corruption of stored data.

cilefen’s picture

Priority: Major » Critical
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

@MarcoDeJong

It may be, but I cannot reproduce it on a newly-installed D8 site.

For anyone experiencing this issue, it is super-important to have a clear, numbered, list of the steps to reproduce in the issue summary. It is important to put the steps in the issue summary rather than in a comment, because contributors are busy people and don't always have time to read essays or to watch screencasts.

Looking at #7, environment details may come into play so it would help to mention the version of PHP and other platform details.

For example, the steps in @zenphp listed in #16 are a step in the right direction. But as I mentioned above, it is better to put them in the issue summary. I could not reproduce any of the symptoms seen in #16, with or without Token installed.

  • At some point, the Token module was mentioned, but not its version. Token is in Beta. There could be a common contrib module affecting all sites. That is why it is important to find the minimum conditions that produce the bug.
  • No errors were logged anywhere? Really? It's possible. But there should be a mention as to whether the browser console, Drupal's watchdog and the PHP error log have been checked for anything.

I realize this is a serious problem for those affected, but we need a better error report. I am going to make this critical but mark it postponed on needing more info. Please add some!

cilefen’s picture

One more thing:

Using the browser dev tools, you can see the data that was posted to the server and what was returned. It would be good to see both of those things.

zenphp’s picture

Okay, I found out what was causing this in my instance, and it might be worth looking into for others. Our staging/production servers have the Suhosin hardening patch set for PHP installed. There are settings in there that limit the length of variable names introduced via GET, POST, COOKIE and REQUEST, and the default lengths are set to 64 characters. In the Edit Menu screen (the bulk drag and drop link list with enabled checkboxes) many of the components are now identified with UUID's prefixed with plugin identifiers. These array index values exceed the 64 character limit allowed by suhosin, and are stripped out of the incoming request. By default there are no logs of this, it appears to be a completely silent action. Drupal interprets these missing items as 0 or false values, causing the unpredictable behaviors here.

So check to see if you have Suhosin installed, and if so try the following configuration settings:

suhosin.cookie.max_array_index_length 128
suhosin.cookie.max_name_length 128
suhosin.cookie.max_totalname_length 512

suhosin.get.max_array_index_length 128
suhosin.get.max_name_length 128
suhosin.get.max_totalname_length 512

suhosin.post.max_array_index_length 128
suhosin.post.max_name_length 128
suhosin.post.max_totalname_length 512

suhosin.request.max_array_index_length 128
suhosin.request.max_totalname_length 512
suhosin.request.max_varname_length 128

These have cleared up the problem for me.

adminMN2023’s picture

Version 8.2.5 has same issue with same reproduced steps in #11.

Stephen_WTD’s picture

Confirm that in Drupal 8.2.6 I still had the main menu not saving settings and resetting.
With zenphp's fix in #21 I modified Suhosin's settings via drupal's htaccess file eg
inserted #21 adjustments with addition of php_value after

<IfModule mod_php5.c>
php_value suhosin.cookie.max_array_index_length 128
...
adminMN2023’s picture

Stephen_WTD

Would you post the exact code you added? I can't the earlier #21 adjustments and it looks like, if I'm reading your comment correctly, your code might be truncated? (...)

zenphp’s picture

To do this in the .htaccess file you would need a block similiar to:

<IfModule mod_php5.c>
  php_value suhosin.cookie.max_array_index_length 128
  php_value suhosin.cookie.max_name_length 128
  php_value suhosin.cookie.max_totalname_length 512

  php_value suhosin.get.max_array_index_length 128
  php_value suhosin.get.max_name_length 128
  php_value suhosin.get.max_totalname_length 512

  php_value suhosin.post.max_array_index_length 128
  php_value suhosin.post.max_name_length 128
  php_value suhosin.post.max_totalname_length 512

  php_value suhosin.request.max_array_index_length 128
  php_value suhosin.request.max_totalname_length 512
  php_value suhosin.request.max_varname_length 128
</IfModule>

I think that this issue could be closed at this point, it seems that things work as expected when PHP works as expected. It might be worth submitting a note to the install documentation that Suhosin cannot be used with default settings though, or adding settings similar to these to the default htaccess provided with D8.

dawehner’s picture

Yeah suhosin is a common problem in Drupal projects. The permission page has a good history of being broken due to that.

I would argue we should close this as "closed (worked as designed)", but maybe we could add some hook_requirements() warning, when suhosin is configured to not allow to many POST variables.

dilovan’s picture

Drupal 8.3.5: Re-ordering menu items then save, or flushing all caches was setting all menu items to disabled! I had to edit them and enable one by one.

Changing PHP version from 5.6 to 7.0 has fixed this problem for me!

sprite’s picture

This problem is surely experienced by a wide swath of Drupal 8 users.

sprite’s picture

The fix suggestion at #25 did not work for me.

henrysingleton’s picture

sprite,

We had a similar issue on a very big menu, and had to update the following PHP input limit settings:

max_input_vars=10000
max_input_nesting_level=1000

I'd suggest looking at just how many input_vars/input_next_levels are attempting to be posted and add a buffer rather than just blindly changing these values.

sprite’s picture

Status: Postponed (maintainer needs more info) » Active
sprite’s picture

@henrysingleton

changed php to:


max_input_vars=11000
max_input_nesting_level=2000

The changes did not fix the problem.
I've experienced the inability to make changes on the menu item list page bug on every server and every D8 install since starting to use D8.

cilefen’s picture

Is suhosin installed? How many menu items are in play?

catch’s picture

Version: 8.2.1 » 8.4.x-dev

We have #1565704: Core interfaces can go over max_input_vars and #1203766: With large number of permissions /admin/people/permissions becomes unusable as well as #2507019: Determine how much POST truncation protection is needed and add tests for it and several other issues related to this, usually about max_input_vars rather than suhosin. I think a hook_requirements() would be worth doing for either or both, would need to write a handbook page with troubleshooting steps and mitigations to link to.

We should also really look at modernizing these interfaces (i.e. could we AJAX-update temp store for drag and drop? the permissions page has usability issues already which mirror the max_input_vars problem).

joelseguin’s picture

The php.ini modification mentioned in #30 did the trick for me.

I'm using admin toolbar which I beleive adds quite a few items to the administration menu. No issue with the menu until I added a custom item (link) to it. All my modules and core were up to date when I noticed the issue.

adminMN2023’s picture

I initially tried what was done in #30. But had to keep increasing values with no fixed result.

So while #30 worked for some folks - Suhosin adjustment did work for me.

What is missing from the discussion is what safe limits for each of these variables from a security standpoint - they are limited for a reason. It may be out-of-scope for this page - but seems relevant.

catch’s picture

Title: Cannot add Sub Menu Items (Automatically disable upon save) » Add warnings for suhosin_max* and max_input_vars interfering with massive core forms
Category: Bug report » Task
Issue summary: View changes
Issue tags: -Needs steps to reproduce

Re-titling this and changing it to a task.

I think the silent loss of data and lack of workaround in some cases means this should probably stay critical, however we should just work on warning people about the php.ini settings in this issue, and promote the interface refactoring issues to major.

catch’s picture

Title: Add warnings for suhosin_max* and max_input_vars interfering with massive core forms » Select lists on drag and drop interfaces can break either browsers or exceed PHP server limits for forms
Category: Task » Bug report
Issue summary: View changes

Thought about it some more, I think we should try to fix the root cause here, it may actually be easier than warning, especially for drag and drop.

Updated the issue summary again.

catch’s picture

Issue summary: View changes
cilefen’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andeersg’s picture

Is there a solution/workaround to this? I encountered it on a site with approximately 300 menu items. When I saved, the last 50 got disabled. Only solution is to edit each item individually and change weight from there.

When I increased max_input_vars from 1000 to 3000 the error disappeared.

SKAUGHT’s picture

..at the end of the day: yes, it is a 'one of those' basic php freshly installed settings that needs to be handled -- given that scale of your project (all the modules and awesome magic tools that we install...)

What 'Drupal' could do:
a. give a related notice during site install.
b. give related notice on Status page of low settings, such as these..

jegaudin’s picture

Thank you andeers #42
This :

When I increased max_input_vars from 1000 to 3000 the error disappeared.

did the trick.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

I'm wondering, could we add a feature which validates the amount of form elements which are sent via POST? If this is hit, don't save anything?

SKAUGHT’s picture

it would be more beneficial to have some calculation based off of php's 'current' max_input_vars setting and the number of form elements that could be output before any page load. Problem is having a way to be able have a form be aware enough that what it's about to render is just going blow out these related memory settings. Ajax form's (ie: forms with multiple field adds..) will compound that problem in all situations..

this along with my previous comments..

effulgentsia’s picture

could we add a feature which validates the amount of form elements which are sent via POST? If this is hit, don't save anything?

I think the easiest way to do this is to add a hidden element to the end of the form (or move the existing form_id or form_token element to the end, via e.g., giving it a large #weight). Then that would be empty in a situation where there are max_input_vars or more elements before it. At a minimum, that would result in the form not saving anything.

If we do this via a new hidden element, then we could also add a friendly validation error based on it being empty (rather than piggy backing on the errors that happen when form_id or form_token are empty).

Note that FormBuilder already has this code in it:

if ($ajax_form_request && !$request->request->has('form_id')) {
  throw new BrokenPostRequestException($this->getFileUploadMaxSize());
}

But that only runs during AJAX submissions, and it's assuming that the lack of a $_POST['form_id'] is due to a file upload maximum, as opposed to the other ways that POST truncation can occur.

it would be more beneficial to have some calculation based off of php's 'current' max_input_vars setting and the number of form elements that could be output before any page load.

It should certainly be possible to count the form elements that we're outputting during the initial form render, but then what do we do when that counter exceeds max_input_vars? At a minimum, I guess we can output an error message with a link to some documentation? The tricky part is that the correct action to take is situation-dependent. It might be to increase the setting. Or it might be to decrease the form size in some way (via whatever Drupal configuration or contrib modules allow for that).

catch’s picture

Detecting this somehow is a good idea, but seems more appropriate for #1565704: Core interfaces can go over max_input_vars. However I think we should try to actually fix the drag and drop interface in this issue so that it doesn't run into the problem at all - i.e. change the weight select to a text field or similar.

effulgentsia’s picture

The current issue title is "Select lists on drag and drop interfaces can break either browsers or exceed PHP server limits for forms".

i.e. change the weight select to a text field or similar

How would that improve the "or exceed PHP server limits for forms" part?

Is the suggestion then to re-scope this issue to just "Select lists on drag and drop interfaces can break browsers"?

SKAUGHT’s picture

Issue tags: +forms, +data loss, +memory limit

because it's not just select lists.. it can be caused by any and all form elements with or without ajax.. I can't see how sticking our head in the sand to one aspect will help this issue that i know has been a concern -- forever, not just for drupal 8, 7, 6...

there are other linked issues to this one as is. as well as other non-linked. certainly, if we search we'll find more like reports..

SKAUGHT’s picture

catch’s picture

@effulgentsia if I understand correctly, each option on a select list counts as an input variable, so when we show say 100 menu items each with a select list containing 100 weight options, that results in 10,000 input vars.

If however each of those select lists was a text field, it would be only 100 input vars.

Berdir’s picture

> @effulgentsia if I understand correctly, each option on a select list counts as an input variable, so when we show say 100 menu items each with a select list containing 100 weight options, that results in 10,000 input vars.

That's news to me? A single-value select sends only one value to the server? Actually building the form/html is a different story of course and does require more memory/time than a textfield.

catch’s picture

hmm you're right of course it doesn't send everything in the select list, in which case we're just dealing with items x fields (but still managing to go over).

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

catch’s picture

Title: Select lists on drag and drop interfaces can break either browsers or exceed PHP server limits for forms » Drag and drop interfaces can break either browsers or exceed PHP server limits for forms
Priority: Critical » Major

Re-titling and downgrading to major. I think #1565704: Core interfaces can go over max_input_vars is the actual critical issue here.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

esolitos’s picture

Version: 8.9.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.