From 649348cf5bc0c799c6081d5ae2e3677ca3cbe01f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 9 Sep 2020 03:55:07 +0000 Subject: [PATCH] Code Modernization: Remove unnecessary reference sign from `get_comment()` definition. This fixes a PHP 8 "argument must be passed by reference, value given" error when using `array_map( 'get_comment', ... )`. Object variables in PHP 5+ contain a reference to the object, and it's the reference that's passed around. Note: This reverts [48838], which is now redundant. Follow-up to a similar change for `get_post()` in [21572]. See #50913. Built from https://develop.svn.wordpress.org/trunk@48961 git-svn-id: http://core.svn.wordpress.org/trunk@48723 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-comment-query.php | 3 +-- wp-includes/comment.php | 2 +- wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/wp-includes/class-wp-comment-query.php b/wp-includes/class-wp-comment-query.php index e185ceb40e..bbc6fe2d66 100644 --- a/wp-includes/class-wp-comment-query.php +++ b/wp-includes/class-wp-comment-query.php @@ -481,8 +481,7 @@ class WP_Comment_Query { $_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) ); // Convert to WP_Comment instances. - array_walk( $_comments, 'get_comment' ); - $comments = $_comments; + $comments = array_map( 'get_comment', $_comments ); if ( $this->query_vars['hierarchical'] ) { $comments = $this->fill_descendants( $comments ); diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 150acd6f1a..10e9d864ad 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -192,7 +192,7 @@ function get_approved_comments( $post_id, $args = array() ) { * respectively. Default OBJECT. * @return WP_Comment|array|null Depends on $output value. */ -function get_comment( &$comment = null, $output = OBJECT ) { +function get_comment( $comment = null, $output = OBJECT ) { if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) { $comment = $GLOBALS['comment']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index feb53399cd..55f744315b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48960'; +$wp_version = '5.6-alpha-48961'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.