[wp-trac] [WordPress Trac] #48249: Check for int instead of null in new submenu priority implementation

WordPress Trac noreply at wordpress.org
Tue Oct 8 09:02:36 UTC 2019


#48249: Check for int instead of null in new submenu priority implementation
--------------------------+-----------------------------
 Reporter:  david.binda   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Similarly to the PHP warning reported in
 https://core.trac.wordpress.org/ticket/39776#comment:34 , I've run into
 multiple instances where developers are passing in an incorrect number of
 params to the `add_submenu_page` function when testing the 5.3 beta 2.

 It's mainly due to a confusion with `add_menu_page`, which takes the
 `$icon_url` param, while the `add_submenu_page` does not.

 Similar cases, which would produce issues, can be found in the wild. Some
 GitHub examples:
 https://github.com/mallory/freeandsecure/blob/cce8e2928e63d117e56d771346d1e2514571efb2
 /wp-content/plugins/speakout/includes/admin.php#L19
 https://github.com/miloman/Find-a-voice/blob/8a66e93b1dd69691ae19b481b0a8a5b4d52fa9f6/admin/admin_menu.php#L66

 For proper backward compatibility of the new functionality, I'm proposing
 a better check for the type of the `$position` param. Currently the code
 is checking for `null` (default value/type in case the param is not set).
 But the code expects an `int`. So, perhaps, doing an `is_int` check would
 be more suitable.

 Related ticket: #39776
 Related revision: r46197

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48249>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list