[wp-trac] [WordPress Trac] #36590: POST['nav-menu-data'] breaks other POST values
WordPress Trac
noreply at wordpress.org
Thu Apr 21 01:49:45 UTC 2016
#36590: POST['nav-menu-data'] breaks other POST values
-------------------------------------+-------------------------------------
Reporter: Unyson | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.5.1
Component: Menus | Version: 4.5
Severity: normal | Resolution:
Keywords: needs-patch needs- | Focuses: javascript,
testing | administration
-------------------------------------+-------------------------------------
Comment (by ericlewis):
Replying to [comment:9 keraweb]:
> You'll need to use {{{array_replace_recursive()}}} to properly add the
values.
Ah thank you!
> Also, how does the {{{preg_match()}}} compare to {{{explode()}}}
performance wise?
Good question! On a menu of 500 items (presumably with ~5000 POST
variables, and 5000 `preg_match()` invocations)
`wp_expand_nav_menu_post_data()` execution takes about 25ms on my
computer. The entire request takes about ~5 seconds, presumably due to the
cost of updating 500 menu item objects in the DB. I think here the
`preg_match()` gives us a bit of readability without notable decline in
perf.
> Also, the current function does the array merge on the whole $_POST
value. I can imagine with larger menu's this can get slower than to do
this merge/replace on the first array key that is found. The code has a
lot less to loop through for every new key that is found.
We'll have to merge onto the $_POST global because we're dealing with one
POST variable at a time, which could represent a nested key (e.g.
`a[1][2][3]`) and the next could be a deep-sibling of the previous (e.g.
`a[1][2][4]`).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36590#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list