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
This commit is contained in:
Sergey Biryukov 2020-08-15 13:40:03 +00:00
parent 756de63216
commit d3a3862248
4 changed files with 12 additions and 9 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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 );

View File

@ -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.