From 5d2e8afebd5ed633ca66004dbb15e6c8427d4e8a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 22 Jun 2022 14:55:11 +0000 Subject: [PATCH] Code Modernization: Use the integer portion of an item position in `add_submenu_page()`. This fixes an `Implicit conversion from float to int loses precision` PHP 8.1 deprecation notice when adding a new admin menu item with a `float` value passed as the `$position` parameter. This change is covered by existing unit tests and addresses 8 errors when running the test suite on PHP 8.1. References: * [https://php.watch/versions/8.1/deprecate-implicit-conversion-incompatible-float-string PHP 8.1: Implicit incompatible float to int conversion is deprecated] * [https://wiki.php.net/rfc/implicit-float-int-deprecate PHP RFC: Deprecate implicit non-integer-compatible float to int conversions] Follow-up to [52569], [53104]. Props jrf. See #55656, #54798. Built from https://develop.svn.wordpress.org/trunk@53555 git-svn-id: http://core.svn.wordpress.org/trunk@53144 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 1 + wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 7834abe6f2..3053971e48 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1454,6 +1454,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, // For negative or `0` positions, prepend the submenu. array_unshift( $submenu[ $parent_slug ], $new_sub_menu ); } else { + $position = absint( $position ); // Grab all of the items before the insertion point. $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true ); // Grab all of the items after the insertion point. diff --git a/wp-includes/version.php b/wp-includes/version.php index b6cde8f933..370d7f075b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53554'; +$wp_version = '6.1-alpha-53555'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.