diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
index 35d33e4e50..7d059db9af 100644
--- a/src/wp-includes/comment-template.php
+++ b/src/wp-includes/comment-template.php
@@ -59,8 +59,9 @@ function get_comment_author( $comment_ID = 0 ) {
  *                                   Default current comment.
  */
 function comment_author( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
-	$author  = get_comment_author( $comment );
+	$comment    = get_comment( $comment_ID );
+	$comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_ID;
+	$author     = get_comment_author( $comment );
 
 	/**
 	 * Filters the comment author's name for display.
@@ -71,7 +72,7 @@ function comment_author( $comment_ID = 0 ) {
 	 * @param string $author     The comment author's username.
 	 * @param string $comment_ID The comment ID as a numeric string.
 	 */
-	echo apply_filters( 'comment_author', $author, $comment->comment_ID );
+	echo apply_filters( 'comment_author', $author, $comment_ID );
 }
 
 /**
diff --git a/tests/phpunit/tests/comment/getCommentAuthor.php b/tests/phpunit/tests/comment/getCommentAuthor.php
new file mode 100644
index 0000000000..83625fe286
--- /dev/null
+++ b/tests/phpunit/tests/comment/getCommentAuthor.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @group comment
+ *
+ * @covers ::get_comment_author
+ */
+class Tests_Comment_GetCommentAuthor extends WP_UnitTestCase {
+	protected static $comments = array();
+
+	public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+		unset( $GLOBALS['comment'] );
+
+		$comment_ids                = $factory->comment->create_post_comments( 0, 1 );
+		$user_generated_comment_ids = $factory->comment->create_post_comments( 0, 1, array(
+			'user_id'        => $factory->user->create(),
+			'comment_author' => '',
+		) );
+		self::$comments = array_map(
+			'get_comment',
+			array_merge(
+				$comment_ids,
+				$user_generated_comment_ids
+			)
+		);
+	}
+
+	public function test_no_comment() {
+		$author = get_comment_author();
+		$this->assertSame( 'Anonymous', $author );
+	}
+
+	public function test_invalid_comment() {
+		$comment            = end( self::$comments );
+		$invalid_comment_id = $comment->comment_ID + 1;
+		$author             = get_comment_author( $invalid_comment_id );
+		$this->assertSame( 'Anonymous', $author );
+	}
+
+	public function test_global_comment() {
+		$comment            = reset( self::$comments );
+		$GLOBALS['comment'] = $comment;
+		$author             = get_comment_author();
+		$this->assertSame( $comment->comment_author, $author );
+		unset( $GLOBALS['comment'] );
+	}
+
+	public function test_comment_arg() {
+		$comment = reset( self::$comments );
+		$author  = get_comment_author( $comment );
+		$this->assertSame( $comment->comment_author, $author );
+	}
+
+	public function test_comment_by_registered_user_with_empty_comment_author_name() {
+		$comment = end( self::$comments );
+		$user    = get_userdata( $comment->user_id );
+		$author  = get_comment_author( $comment );
+		$this->assertSame( $user->display_name, $author );
+	}
+
+}
