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
This commit is contained in:
Sergey Biryukov 2020-09-09 03:55:07 +00:00
parent 7c60a660f1
commit 649348cf5b
3 changed files with 3 additions and 4 deletions

View File

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

View File

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

View File

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