Make WordPress Core

Ticket #48599: 48599.patch

File 48599.patch, 710 bytes (added by ayeshrajans, 6 years ago)

These count() warnings can pop up at unexpected places. The attached patch checks if the variable is countable (WordPress provides a polyfill for is_countable) before attempting to actually call count().

  • src/wp-admin/includes/plugin.php

    diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php
    index 32a37f106a..30a37d5ad9 100644
    a b function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, 
    13891389                $submenu[ $parent_slug ][] = $new_sub_menu;
    13901390        } else {
    13911391                // If position is equal or higher than the number of items in the array, append the submenu.
    1392                 if ( $position >= count( $submenu[ $parent_slug ] ) ) {
     1392                if ( is_countable( $submenu[ $parent_slug ] ) && $position >= count( $submenu[ $parent_slug ] ) ) {
    13931393                        $submenu[ $parent_slug ][] = $new_sub_menu;
    13941394                } else {
    13951395                        // Test for a negative position.