WordPress.org

Make WordPress Core

Changeset 48961


Ignore:
Timestamp:
09/09/2020 03:53:50 AM (11 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r48838 r48961  
    482482
    483483        // Convert to WP_Comment instances.
    484         array_walk( $_comments, 'get_comment' );
    485         $comments = $_comments;
     484        $comments = array_map( 'get_comment', $_comments );
    486485
    487486        if ( $this->query_vars['hierarchical'] ) {
  • trunk/src/wp-includes/comment.php

    r48822 r48961  
    193193 * @return WP_Comment|array|null Depends on $output value.
    194194 */
    195 function get_comment( &$comment = null, $output = OBJECT ) {
     195function get_comment( $comment = null, $output = OBJECT ) {
    196196    if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) {
    197197        $comment = $GLOBALS['comment'];
Note: See TracChangeset for help on using the changeset viewer.