diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index fe17e2f043..3fd466f933 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -306,7 +306,7 @@ function get_comment_author_url( $comment_ID = 0 ) { if ( ! empty( $comment ) ) { $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; $url = esc_url( $author_url, array( 'http', 'https' ) ); - $id = $comment->ID; + $id = $comment->comment_ID; } /** diff --git a/tests/phpunit/tests/comment/getCommentAuthorUrl.php b/tests/phpunit/tests/comment/getCommentAuthorUrl.php new file mode 100644 index 0000000000..b2710628aa --- /dev/null +++ b/tests/phpunit/tests/comment/getCommentAuthorUrl.php @@ -0,0 +1,27 @@ +assertSame( $id, $comment->comment_ID ); + + return $url; + } + + /** + * @ticket 41334 + */ + public function test_comment_author_url_passes_correct_comment_id() { + $comment = self::factory()->comment->create_and_get( array( + 'comment_post_ID' => 0, + ) ); + + add_filter( 'get_comment_author_url', array( $this, 'get_comment_author_url_filter' ), 99, 3 ); + + get_comment_author_url( $comment ); + + remove_filter( 'get_comment_author_url', array( $this, 'get_comment_author_url_filter' ), 99 ); + } +}