[wp-trac] [WordPress Trac] #48249: Check for int instead of null in new submenu priority implementation
WordPress Trac
noreply at wordpress.org
Mon Oct 21 20:51:23 UTC 2019
#48249: Check for int instead of null in new submenu priority implementation
-------------------------------------------+------------------------
Reporter: david.binda | Owner: audrasjb
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 5.3
Component: Menus | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch commit dev-reviewed | Focuses:
-------------------------------------------+------------------------
Changes (by desrosj):
* keywords: has-patch commit dev-feedback => has-patch commit dev-reviewed
Comment:
[attachment:"48249.diff"] looks good to me as well.
However, I am wondering if a `_doing_it_wrong()` should be added here.
This may not be possible to add for 5.3 (since we are in string freeze),
but a follow up ticket could be created for 5.3.1.
Because passing incorrect parameters to the function is happening in the
wild, that may help better educate developers when they are using
`add_submenu_page()` incorrectly. Something like:
{{{
if ( ! is_int( $position ) ) {
if ( null !== $position ) {
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: add_submenu_page() */
__( 'The seventh parameter passed to %s
should be an integer.' ),
'<code>add_submenu_page()</code>'
),
'5.3.0'
);
}
$submenu[ $parent_slug ][] = $new_sub_menu;
} else {
}}}
Applying the `commit dev-reviewed` keywords so [attachment:"48249.diff"]
can be committed, but would like to know what others think of the
`_doing_it_wrong()` suggestion.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48249#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list