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.
Built from https://develop.svn.wordpress.org/trunk@58335


git-svn-id: http://core.svn.wordpress.org/trunk@57791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-06-04 15:29:13 +00:00
parent 1c4a732f5f
commit 4c61d32c3c
2 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@
function get_comment_author( $comment_id = 0 ) {
$comment = get_comment( $comment_id );
$comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : $comment_id;
$comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id;
if ( empty( $comment->comment_author ) ) {
$user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-58334';
$wp_version = '6.6-alpha-58335';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.