[wp-trac] [WordPress Trac] #52035: The `add_submenu_page()` position is ignored.
WordPress Trac
noreply at wordpress.org
Mon Jul 8 14:46:55 UTC 2024
#52035: The `add_submenu_page()` position is ignored.
-------------------------------------+------------------------------
Reporter: Howdy_McGee | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: administration
-------------------------------------+------------------------------
Comment (by leogermani):
Hi @rajinsharwar, thank you so much for working on this!
Your patch works fine in my tests and solves all the issues.
I do think we could take this opportunity to add a few more tests though,
it should be simple.
There are 2 things we are not testing:
1. All the tests that use that data provider add only one submenu with a
custom position, after adding several submenus with no position informed.
One of the things we are fixing here is the addition of several submenus
with custom positions, I think we should test that.
2. Now that you have changed how the array keys are handled, I think we
could have a better test to check if the menu felt in the right position.
The data provider you are passing on `array( 123456, 123456 )` for example
looks like a weak test to me. We are only testing that the key was
preserved, but we are not testing whether `ksort` had the expected
behavior.
Maybe we could add a test that resets the array keys, or loops through the
submenus, and test the actual position of each item.
Lastly, I'm not sure if this deserves a Dev Note, since we are changing
how menus are stored, no longer with sequential numeric keys.
(let me know and I can help writing tests if you want)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52035#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list