[wp-trac] [WordPress Trac] #48599: Warning: count(): Parameter must be an array or an object that implements Countable in ../wp-admin/includes/plugin.php on line 1392

WordPress Trac noreply at wordpress.org
Thu Nov 14 21:45:08 UTC 2019


#48599: Warning: count(): Parameter must be an array or an object that implements
Countable in ../wp-admin/includes/plugin.php on line 1392
----------------------------+---------------------
 Reporter:  ispreview       |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  5.3.1
Component:  Administration  |     Version:  5.3
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:  ui
----------------------------+---------------------

Comment (by NextScripts):

 Since we been mentioned here. Bug is really in WP itself.

 You can install a clean WP 5.3 without any plugins and then install and
 activate this simple plugin that just creates one menu item with two
 submenus:

 {{{#!php
 <?php
 /*
 Plugin Name: Test Plugin
 Version: 1.0.0
 */

 add_action( 'admin_menu', 'testPlg_adminMenu' );

 function testPlg_adminMenu() {
     add_menu_page( 'Test Plugin',
 'Test|Plugin','manage_options','testPlg','testPlg_shoPage1');
     add_submenu_page(
       'testPlg','SubMenu 1',
       'SubMenu 1', 'manage_options',
       'testPlg','testPlg_shoPage1',
       1
     );
     add_submenu_page(
        'testPlg','SubMenu 1',
        'SubMenu 1', 'manage_options',
        'testPlg-page1',
        'testPlg_shoPage2',
        2
     );
 }
 ?>
 }}}

 You will get ''“Warning: count(): Parameter must be an array or an object
 that implements Countable in /home/oradell/public_html/wp-
 admin/includes/plugin.php on line 1392”''

 Now edit the code and remove last parameters from add_submenu_page

 {{{#!php
 <?php
 /*
 Plugin Name: Test Plugin
 Version: 1.0.0
 */

 add_action( 'admin_menu', 'testPlg_adminMenu' );

 function testPlg_adminMenu() {
     add_menu_page( 'Test Plugin',
 'Test|Plugin','manage_options','testPlg','testPlg_shoPage1');
     add_submenu_page(
       'testPlg','SubMenu 1',
       'SubMenu 1', 'manage_options',
       'testPlg','testPlg_shoPage1'
     );
     add_submenu_page(
        'testPlg','SubMenu 1',
        'SubMenu 1', 'manage_options',
        'testPlg-page1',
        'testPlg_shoPage2'
     );
 }
 ?>
 }}}

 Everything is fine now.

 According to
 https://developer.wordpress.org/reference/functions/add_submenu_page/ that
 last parameter is int and it should work.


 {{{
 $position
 (int) (Optional) The position in the menu order this item should appear.

 Default value: null
 }}}


 It worked ok before 5.3

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48599#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list