From d3a3862248c7c94430ba8e329dbe74b6c2f76510 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 15 Aug 2020 13:40:03 +0000 Subject: [PATCH] Code Modernization: Fix PHP 8 deprecation notices for optional function parameters declared before required parameters. As it already was not possible to pass the required parameters without also passing the optional one anyway, removing the default value for the (not so) optional parameters should not affect backward compatibility. This change affects three functions in core: * `get_comment_delimited_block_content()` * `do_enclose()` * `_wp_delete_tax_menu_item()` Props jrf, ayeshrajans, desrosj. Fixes #50343. Built from https://develop.svn.wordpress.org/trunk@48794 git-svn-id: http://core.svn.wordpress.org/trunk@48556 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 9 +++++---- wp-includes/functions.php | 6 ++++-- wp-includes/nav-menu.php | 4 ++-- wp-includes/version.php | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index dfe642ab82..3c83c00dc3 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -397,12 +397,13 @@ function strip_core_block_namespace( $block_name = null ) { * * @since 5.3.1 * - * @param string $block_name Block name. - * @param array $block_attributes Block attributes. - * @param string $block_content Block save content. + * @param string|null $block_name Block name. Null if the block name is unknown, + * e.g. Classic blocks have their name set to null. + * @param array $block_attributes Block attributes. + * @param string $block_content Block save content. * @return string Comment-delimited block content. */ -function get_comment_delimited_block_content( $block_name = null, $block_attributes, $block_content ) { +function get_comment_delimited_block_content( $block_name, $block_attributes, $block_content ) { if ( is_null( $block_name ) ) { return $block_content; } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 863268c7bd..8d8e5001e2 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -830,14 +830,16 @@ function wp_extract_urls( $content ) { * @since 1.5.0 * @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was * updated to accept a post ID or a WP_Post object. + * @since 5.6.0 The `$content` parameter is no longer optional, but passing `null` to skip it + * is still supported. * * @global wpdb $wpdb WordPress database abstraction object. * - * @param string $content Post content. If `null`, the `post_content` field from `$post` is used. + * @param string|null $content Post content. If `null`, the `post_content` field from `$post` is used. * @param int|WP_Post $post Post ID or post object. * @return null|bool Returns false if post is not found. */ -function do_enclose( $content = null, $post ) { +function do_enclose( $content, $post ) { global $wpdb; // @todo Tidy this code and make the debug code optional. diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 53d4a15d0e..220f250e0b 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -1054,11 +1054,11 @@ function _wp_delete_post_menu_item( $object_id = 0 ) { * @since 3.0.0 * @access private * - * @param int $object_id Optional. The ID of the original object being trashed. Default 0. + * @param int $object_id The ID of the original object being trashed. * @param int $tt_id Term taxonomy ID. Unused. * @param string $taxonomy Taxonomy slug. */ -function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) { +function _wp_delete_tax_menu_item( $object_id, $tt_id, $taxonomy ) { $object_id = (int) $object_id; $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy ); diff --git a/wp-includes/version.php b/wp-includes/version.php index ea58867014..51adf874db 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48793'; +$wp_version = '5.6-alpha-48794'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.