Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#47983 new enhancement

Menus: Only send non-empty values on menu save on nav-menus.php

Reported by: metalandcoffee's profile metalandcoffee Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

In an effort to do some admin navigation menu customization (adding additional metaboxes/properties to individual menu items), I noticed that all menu properties (even ones that may be hidden due to "Screen Options") are being submitted to the server. And it actually began to cause the following PHP warning:

[05-Sep-2019 21:48:58 UTC] PHP Warning:  Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0

Would it be better to make sure only menu properties that have been explicitly set are submitted to the server and saved to the database?

When building a nav-menu and utilizing custom links the entered value isn't trimmed.
Once you click 'Add to Menu':
If you have whitespace at the start: no url added to the custom link in the menu item
If you have whitespace at the end: %20 is added to the custom linkprevent PHP warning max_input_vars

Change History (3)

#1 @metalandcoffee
5 years ago

Ignore the text after "Would it be better to make sure only menu properties that have been explicitly set are submitted to the server and saved to the database?" Mistakenly copy and pasted unrelated text :-)

#2 @SergeyBiryukov
5 years ago

  • Component changed from General to Menus
  • Description modified (diff)

Previously: #14134

#3 @metalandcoffee
5 years ago

Here is some additional information on this issue.

I have a very extensive primary menu structure that contains 93 menu items total. So when all of the properties for each menu item get sent to server via the $_POST method, PHP issues the warning mentioned above. I think it'd be beneficial in the long run to limit the number of input variables sent to the server.

See: https://www.php.net/manual/en/info.configuration.php#ini.max-input-vars

Note: See TracTickets for help on using tickets.