WordPress.org

Make WordPress Core

Changeset 48794


Ignore:
Timestamp:
08/15/2020 01:38:52 PM (13 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r48629 r48794  
    398398 * @since 5.3.1
    399399 *
    400  * @param string $block_name       Block name.
    401  * @param array  $block_attributes Block attributes.
    402  * @param string $block_content    Block save content.
     400 * @param string|null $block_name       Block name. Null if the block name is unknown,
     401 *                                      e.g. Classic blocks have their name set to null.
     402 * @param array       $block_attributes Block attributes.
     403 * @param string      $block_content    Block save content.
    403404 * @return string Comment-delimited block content.
    404405 */
    405 function get_comment_delimited_block_content( $block_name = null, $block_attributes, $block_content ) {
     406function get_comment_delimited_block_content( $block_name, $block_attributes, $block_content ) {
    406407    if ( is_null( $block_name ) ) {
    407408        return $block_content;
  • trunk/src/wp-includes/functions.php

    r48695 r48794  
    831831 * @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was
    832832 *              updated to accept a post ID or a WP_Post object.
     833 * @since 5.6.0 The `$content` parameter is no longer optional, but passing `null` to skip it
     834 *              is still supported.
    833835 *
    834836 * @global wpdb $wpdb WordPress database abstraction object.
    835837 *
    836  * @param string      $content Post content. If `null`, the `post_content` field from `$post` is used.
     838 * @param string|null $content Post content. If `null`, the `post_content` field from `$post` is used.
    837839 * @param int|WP_Post $post    Post ID or post object.
    838840 * @return null|bool Returns false if post is not found.
    839841 */
    840 function do_enclose( $content = null, $post ) {
     842function do_enclose( $content, $post ) {
    841843    global $wpdb;
    842844
  • trunk/src/wp-includes/nav-menu.php

    r48793 r48794  
    10551055 * @access private
    10561056 *
    1057  * @param int    $object_id Optional. The ID of the original object being trashed. Default 0.
     1057 * @param int    $object_id The ID of the original object being trashed.
    10581058 * @param int    $tt_id     Term taxonomy ID. Unused.
    10591059 * @param string $taxonomy  Taxonomy slug.
    10601060 */
    1061 function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) {
     1061function _wp_delete_tax_menu_item( $object_id, $tt_id, $taxonomy ) {
    10621062    $object_id = (int) $object_id;
    10631063
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r48499 r48794  
    15701570    }
    15711571
    1572     protected function check_post_data( $attachment, $data, $context = 'view', $links ) {
     1572    protected function check_post_data( $attachment, $data, $context = 'view', $links = array() ) {
    15731573        parent::check_post_data( $attachment, $data, $context, $links );
    15741574
Note: See TracChangeset for help on using the changeset viewer.