Make WordPress Core

Opened 9 years ago

Last modified 2 weeks ago

#39196 new defect (bug)

When saving large menus the JSON encoded string was not used. related to #14134

Reported by: budaned's profile budaned Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5
Component: Menus Keywords: has-patch needs-refresh reporter-feedback
Focuses: javascript, administration Cc:

Description

This is a follow-up to #14134.

The solution proposed in #14134 is not properly working. This is because the values of the JSON string are replacing $_POST but later on $_REQUEST was being used. The only reason it seemed to still work is because the post action of the form was populating all the variables, but still failed when the apache, php or suhosin were reached.

In the proposed solution only the JSON string, menu ID and action are submitted by post and then $_POST and $_REQUEST are populated with the data.

Attachments (2)

patch.txt (1.1 KB) - added by budaned 9 years ago.
Patch for fix #14134
39196.diff (396 bytes) - added by ericlewis 9 years ago.

Download all attachments as: .zip

Change History (6)

@budaned
9 years ago

Patch for fix #14134

#1 @budaned
9 years ago

  • Summary changed from When saving largmenus the JSON encoded string was not used. related to #14134 to When saving large menus the JSON encoded string was not used. related to #14134

#2 @swissspidy
9 years ago

  • Keywords has-patch needs-testing added
  • Version changed from trunk to 4.5

Hey there,

Thanks for your report!

This sounds like a regression from 4.5. Pinging @ericlewis as he worked on the original solution.

@ericlewis
9 years ago

#3 @ericlewis
9 years ago

Hey @budaned,

thanks for this bug report! A few questions and notes.

The solution proposed in #14134 is not properly working. This is because the values of the JSON string are replacing $_POST but later on $_REQUEST was being used. The only reason it seemed to still work is because the post action of the form was populating all the variables, but still failed when the apache, php or suhosin were reached.

What do you mean the solution is not working? I can reliably reproduce the problem if I revert the change: in my dev environment only the first 83 items are saved because PHP truncates after 1000 POST values, and enabling the change allows me to save many more than that. Can you share steps to reproduce what you are seeing?

I do see that in a few places we use the $_REQUEST global to access form submitted data on the navigation menu page (1, 2, there are more spots) but I don't see one that would impact the saving of the menu items. The menu item fields are the last values in order in the POST request, so they are the only ones liable to be truncated. The function which extracts the menu item data from the request wp_nav_menu_update_menu_items gets the data from $_POST, and this is the only place in our codebase that touches these variables.

We can certainly set $_REQUEST with the same data, as that's the default behavior of PHP and developers may expect those values to exist, core or otherwise which I've incorporated from your submitted patch in attachment:39196.diff.

#4 @huzaifaalmesbah
2 weeks ago

  • Keywords needs-refresh reporter-feedback added; needs-testing removed

I attempted to apply the attached patch for testing, but ran into issues while applying it against current trunk. During the patch process, backup files such as the following were created:

  • nav-menu.php.orig

This suggests the patch does not apply cleanly and is likely outdated.

Given the age of this ticket and the amount of changes in core since the patch was created, the patch likely needs to be refreshed against current trunk before meaningful testing can be performed.

Since the patch cannot currently be tested against trunk, I have removed the needs-testing keyword. Without a patch that applies cleanly to current core, testing is not meaningful.

Marking as needs-refresh.

Also adding reporter-feedback to confirm whether this issue is still reproducible in current WordPress or if it has already been resolved.

Note: See TracTickets for help on using tickets.