[wp-trac] [WordPress Trac] #48249: Check for int instead of null in new submenu priority implementation
WordPress Trac
noreply at wordpress.org
Sun Nov 17 08:16:16 UTC 2019
#48249: Check for int instead of null in new submenu priority implementation
-------------------------------------------------+-------------------------
Reporter: david.binda | Owner: desrosj
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.3
Component: Administration | Version: 5.3
Severity: normal | Resolution: fixed
Keywords: has-patch commit dev-reviewed i18n- | Focuses:
change |
-------------------------------------------------+-------------------------
Comment (by 123host):
I have an interesting thing happening. I have a plugin and in it I create
a menu with submenus.
Since 5.3 _some_ users have had an issue with the plugin and the way it
calls add_submenu_page. But only some.
I couldn't reproduce this on my sites but have now worked with someone
else where it was happening.
admin.php contains
{{{
$petitions = array(
'page_title' => __( 'SpeakOut! Email Petitions',
'speakout' ),
'menu_title' => __( 'SpeakOut!', 'speakout' ),
'capability' => 'publish_posts',
'menu_slug' => 'dk_speakout',
'function' => 'dk_speakout_petitions_page',
'icon_url' => plugins_url( 'speakout/images/blank.png' )
);
$petitions_page = add_menu_page( $petitions['page_title'],
$petitions['menu_title'], $petitions['capability'],
$petitions['menu_slug'], $petitions['function'], $petitions['icon_url'] );
$addnew = array(
'parent_slug' => 'dk_speakout',
'page_title' => __( 'SpeakOut!', 'speakout' ),
'menu_title' => __( 'Petitions', 'speakout' ),
'capability' => 'publish_posts',
'menu_slug' => 'dk_speakout',
'function' => 'dk_speakout_petitions_page',
'position' => 1
);
$addnew_page = add_submenu_page( $addnew['parent_slug'],
$addnew['page_title'], $addnew['menu_title'], $addnew['capability'],
$addnew['menu_slug'], $addnew['function'] , $addnew['position']);
<more submenus snipped>
}}}
Note that I assign ''position'' a value not wrapped in quotes. This is
fine on my sites but not on one I looked at.
It took ages to troubleshoot and discover that on this site it had to be
{{{ 'position' => '1'}}} so I changed the code and on my test site it now
throw the same error they were having without the quotes. {{{Warning:
count(): Parameter must be an array or an object that implements Countable
in /home/user/example.com/wp-admin/includes/plugin.php on line 1392}}}
I do love that if you have a look at plugin.php there are actually only
900 or so lines :P
Is this a problem with my plugin or something going on in the core?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48249#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list