From 875acd7b37ed706f0f73d63661c5782b7939e4d6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 9 Sep 2020 03:53:50 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@48961 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-comment-query.php | 3 +-- src/wp-includes/comment.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index e185ceb40e..bbc6fe2d66 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/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/src/wp-includes/comment.php b/src/wp-includes/comment.php index 150acd6f1a..10e9d864ad 100644 --- a/src/wp-includes/comment.php +++ b/src/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']; }