WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#47983 new enhancement

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

Reported by: metalandcoffee Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords:
Focuses: Cc:
PR Number:

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
3 months 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
3 months ago

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

Previously: #14134

#3 @metalandcoffee
3 months 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.