Make WordPress Core


Ignore:
Timestamp:
06/04/2024 03:27:57 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Comments: Ensure the correct comment ID type is passed to get_comment_author.

The $comment_id parameter of the get_comment_author filter is documented as a numeric string, however in case a non-existing comment ID is passed to the get_comment_author() function, it could be an integer instead.

This commit resolves the issue and adds a PHPUnit test demonstrating the behavior.

Includes updating get_comment_author_url() unit tests for consistency.

Follow-up to [41127], [52818].

Props david.binda.
Fixes #60475.

File:
1 edited

Legend:

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

    r57685 r58335  
    2525    $comment = get_comment( $comment_id );
    2626
    27     $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : $comment_id;
     27    $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
    2828
    2929    if ( empty( $comment->comment_author ) ) {
Note: See TracChangeset for help on using the changeset viewer.