From 9e46e1db2e8cce6bcb4618ac1497833cf84dfa13 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Tue, 11 Aug 2020 05:47:55 +0200
Subject: [PATCH] PHP 8.0: required parameters are no longer allowed after
optional parameters
As it already wasn't possible to pass the required parameters without also passing the optional one anyway, I'm removing the default value for the (not so) optional parameters and documenting the expected value to "skip" the parameter in the docblock instead.
---
src/wp-includes/blocks.php | 8 ++++----
src/wp-includes/functions.php | 6 ++++--
src/wp-includes/nav-menu.php | 5 +++--
.../tests/rest-api/rest-attachments-controller.php | 2 +-
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index dfe642ab82..91d0bd4421 100644
a
|
b
|
function strip_core_block_namespace( $block_name = null ) { |
397 | 397 | * |
398 | 398 | * @since 5.3.1 |
399 | 399 | * |
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. |
| 401 | * @param array $block_attributes Block attributes. |
| 402 | * @param string $block_content Block save content. |
403 | 403 | * @return string Comment-delimited block content. |
404 | 404 | */ |
405 | | function get_comment_delimited_block_content( $block_name = null, $block_attributes, $block_content ) { |
| 405 | function get_comment_delimited_block_content( $block_name, $block_attributes, $block_content ) { |
406 | 406 | if ( is_null( $block_name ) ) { |
407 | 407 | return $block_content; |
408 | 408 | } |
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 863268c7bd..cf1d8462ab 100644
a
|
b
|
function wp_extract_urls( $content ) { |
830 | 830 | * @since 1.5.0 |
831 | 831 | * @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was |
832 | 832 | * 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 |
| 834 | * it is still supported. |
833 | 835 | * |
834 | 836 | * @global wpdb $wpdb WordPress database abstraction object. |
835 | 837 | * |
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. |
837 | 839 | * @param int|WP_Post $post Post ID or post object. |
838 | 840 | * @return null|bool Returns false if post is not found. |
839 | 841 | */ |
840 | | function do_enclose( $content = null, $post ) { |
| 842 | function do_enclose( $content, $post ) { |
841 | 843 | global $wpdb; |
842 | 844 | |
843 | 845 | // @todo Tidy this code and make the debug code optional. |
diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php
index 1881b54247..d8ef881077 100644
a
|
b
|
function _wp_delete_post_menu_item( $object_id = 0 ) { |
1053 | 1053 | * @since 3.0.0 |
1054 | 1054 | * @access private |
1055 | 1055 | * |
1056 | | * @param int $object_id Optional. The ID of the original object being trashed. Default 0. |
| 1056 | * @param int $object_id The ID of the original object being trashed. |
| 1057 | * Pass the integer 0 if the object id is unknown. |
1057 | 1058 | * @param int $tt_id Term taxonomy ID. Unused. |
1058 | 1059 | * @param string $taxonomy Taxonomy slug. |
1059 | 1060 | */ |
1060 | | function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) { |
| 1061 | function _wp_delete_tax_menu_item( $object_id, $tt_id, $taxonomy ) { |
1061 | 1062 | $object_id = (int) $object_id; |
1062 | 1063 | |
1063 | 1064 | $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy ); |
diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php
index bd4ebbf6d0..09297129f4 100644
a
|
b
|
class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control |
1569 | 1569 | $this->assertArrayNotHasKey( 'https://api.w.org/action-publish', $links ); |
1570 | 1570 | } |
1571 | 1571 | |
1572 | | protected function check_post_data( $attachment, $data, $context = 'view', $links ) { |
| 1572 | protected function check_post_data( $attachment, $data, $context = 'view', $links = array() ) { |
1573 | 1573 | parent::check_post_data( $attachment, $data, $context, $links ); |
1574 | 1574 | |
1575 | 1575 | $this->assertArrayNotHasKey( 'content', $data ); |