Index: src/wp-includes/comment-template.php
===================================================================
--- src/wp-includes/comment-template.php	(revision 40115)
+++ src/wp-includes/comment-template.php	(working copy)
@@ -19,20 +19,25 @@
  *
  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
  *									 Default current comment.
- * @return string The comment author
+ * @return string The comment author.
  */
 function get_comment_author( $comment_ID = 0 ) {
 	$comment = get_comment( $comment_ID );
 
-	if ( empty( $comment->comment_author ) ) {
-		if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
+	if ( $comment ) {
+		if ( $comment->comment_author ) {
+			$author = $comment->comment_author;
+		} elseif ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) {
 			$author = $user->display_name;
-		else
-			$author = __('Anonymous');
+		} else {
+			$author = __( 'Anonymous' );
+		}
 	} else {
-		$author = $comment->comment_author;
+		$author = '';
 	}
 
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
+
 	/**
 	 * Filters the returned comment author name.
 	 *
@@ -39,11 +44,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $author     The comment author's username.
-	 * @param int        $comment_ID The comment ID.
-	 * @param WP_Comment $comment    The comment object.
+	 * @param string          $author     The comment author's username.
+	 * @param int             $comment_ID The comment ID.
+	 * @param WP_Comment|null $comment    The comment object.
 	 */
-	return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
 }
 
 /**
@@ -56,8 +61,9 @@
  *									 Default current comment.
  */
 function comment_author( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
-	$author  = get_comment_author( $comment );
+	$comment    = get_comment( $comment_ID );
+	$author     = ( $comment ) ? get_comment_author( $comment ) : '';
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment author's name for display.
@@ -68,7 +74,7 @@
 	 * @param string $author     The comment author's username.
 	 * @param int    $comment_ID The comment ID.
 	 */
-	echo apply_filters( 'comment_author', $author, $comment->comment_ID );
+	echo apply_filters( 'comment_author', $author, $comment_ID );
 }
 
 /**
@@ -79,10 +85,12 @@
  *
  * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
  *									 Default current comment.
- * @return string The current comment author's email
+ * @return string The current comment author's email.
  */
 function get_comment_author_email( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
+	$comment      = get_comment( $comment_ID );
+	$author_email = ( $comment ) ? $comment->comment_author_email : '';
+	$comment_ID   = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment author's returned email address.
@@ -90,11 +98,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $comment_author_email The comment author's email address.
-	 * @param int        $comment_ID           The comment ID.
-	 * @param WP_Comment $comment              The comment object.
+	 * @param string          $author_email The comment author's email address.
+	 * @param int             $comment_ID   The comment ID.
+	 * @param WP_Comment|null $comment      The comment object.
 	 */
-	return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_author_email', $author_email, $comment_ID, $comment );
 }
 
 /**
@@ -114,7 +122,8 @@
  */
 function comment_author_email( $comment_ID = 0 ) {
 	$comment      = get_comment( $comment_ID );
-	$author_email = get_comment_author_email( $comment );
+	$author_email = ( $comment ) ? get_comment_author_email( $comment ) : '';
+	$comment_ID   = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment author's email for display.
@@ -125,7 +134,7 @@
 	 * @param string $author_email The comment author's email address.
 	 * @param int    $comment_ID   The comment ID.
 	 */
-	echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
+	echo apply_filters( 'author_email', $author_email, $comment_ID );
 }
 
 /**
@@ -173,7 +182,8 @@
  *                via the {@see 'comment_email'} filter with antispambot().
  */
 function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
-	$comment = get_comment( $comment );
+	$comment      = get_comment( $comment );
+	$author_email = ( $comment ) ? $comment->comment_author_email : '';
 
 	/**
 	 * Filters the comment author's email for display.
@@ -184,13 +194,13 @@
 	 * @since 1.2.0
 	 * @since 4.1.0 The `$comment` parameter was added.
 	 *
-	 * @param string     $comment_author_email The comment author's email address.
-	 * @param WP_Comment $comment              The comment object.
+	 * @param string          $author_email The comment author's email address.
+	 * @param WP_Comment|null $comment      The comment object.
 	 */
-	$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
+	$email = apply_filters( 'comment_email', $author_email, $comment );
 
-	if ((!empty($email)) && ($email != '@')) {
-	$display = ($linktext != '') ? $linktext : $email;
+	if ( $email && '@' !== $email ) {
+		$display = ( $linktext ) ? $linktext : $email;
 		$return  = $before;
 		$return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
 	 	$return .= $after;
@@ -214,9 +224,10 @@
  * @return string The comment author name or HTML link for author's URL.
  */
 function get_comment_author_link( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
-	$url     = get_comment_author_url( $comment );
-	$author  = get_comment_author( $comment );
+	$comment    = get_comment( $comment_ID );
+	$url        = ( $comment ) ? get_comment_author_url( $comment ) : '';
+	$author     = ( $comment ) ? get_comment_author( $comment ) : '';
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	if ( empty( $url ) || 'http://' == $url )
 		$return = $author;
@@ -234,7 +245,7 @@
 	 * @param string $author     The comment author's username.
 	 * @param int    $comment_ID The comment ID.
 	 */
-	return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
+	return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID );
 }
 
 /**
@@ -261,7 +272,9 @@
  * @return string Comment author's IP address.
  */
 function get_comment_author_IP( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
+	$comment    = get_comment( $comment_ID );
+	$author_IP  = ( $comment ) ? $comment->comment_author_IP : '';
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment author's returned IP address.
@@ -269,11 +282,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $comment_author_IP The comment author's IP address.
-	 * @param int        $comment_ID        The comment ID.
-	 * @param WP_Comment $comment           The comment object.
+	 * @param string          $author_IP  The comment author's IP address.
+	 * @param int             $comment_ID The comment ID.
+	 * @param WP_Comment|null $comment    The comment object.
 	 */
-	return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_author_IP', $author_IP, $comment_ID, $comment );
 }
 
 /**
@@ -301,14 +314,15 @@
  */
 function get_comment_author_url( $comment_ID = 0 ) {
 	$comment = get_comment( $comment_ID );
-	$url = '';
-	$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;
+
+	if ( $comment && 'http://' !== $comment->comment_author_url ) {
+		$author_url = esc_url( $comment->comment_author_url, array( 'http', 'https' ) );
+	} else {
+		$author_url = '';
 	}
 
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
+
 	/**
 	 * Filters the comment author's URL.
 	 *
@@ -315,11 +329,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $url        The comment author's URL.
-	 * @param int        $comment_ID The comment ID.
-	 * @param WP_Comment $comment    The comment object.
+	 * @param string          $author_url The comment author's URL.
+	 * @param int             $comment_ID The comment ID.
+	 * @param WP_Comment|null $comment    The comment object.
 	 */
-	return apply_filters( 'get_comment_author_url', $url, $id, $comment );
+	return apply_filters( 'get_comment_author_url', $author_url, $comment_ID, $comment );
 }
 
 /**
@@ -333,7 +347,8 @@
  */
 function comment_author_url( $comment_ID = 0 ) {
 	$comment    = get_comment( $comment_ID );
-	$author_url = get_comment_author_url( $comment );
+	$author_url = ( $comment ) ? get_comment_author_url( $comment ) : '';
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment author's URL for display.
@@ -344,7 +359,7 @@
 	 * @param string $author_url The comment author's URL.
 	 * @param int    $comment_ID The comment ID.
 	 */
-	echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
+	echo apply_filters( 'comment_url', $author_url, $comment_ID );
 }
 
 /**
@@ -372,12 +387,13 @@
  */
 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
 	$url = get_comment_author_url( $comment );
-	$display = ($linktext != '') ? $linktext : $url;
+
+	$display = ( $linktext ) ? $linktext : $url;
 	$display = str_replace( 'http://www.', '', $display );
 	$display = str_replace( 'http://', '', $display );
 
-	if ( '/' == substr($display, -1) ) {
-		$display = substr($display, 0, -1);
+	if ( '/' == substr( $display, -1 ) ) {
+		$display = substr( $display, 0, -1 );
 	}
 
 	$return = "$before<a href='$url' rel='external'>$display</a>$after";
@@ -531,27 +547,34 @@
  * @since 1.5.0
  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
  *
- * @param string          $d          Optional. The format of the date. Default user's setting.
- * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
- *                                    Default current comment.
+ * @param string          $date_format Optional. The format of the date. Default user's setting.
+ * @param int|WP_Comment  $comment_ID  WP_Comment or ID of the comment for which to get the date.
+ *                                     Default current comment.
  * @return string The comment's date.
  */
-function get_comment_date( $d = '', $comment_ID = 0 ) {
+function get_comment_date( $date_format = '', $comment_ID = 0 ) {
 	$comment = get_comment( $comment_ID );
-	if ( '' == $d )
-		$date = mysql2date(get_option('date_format'), $comment->comment_date);
-	else
-		$date = mysql2date($d, $comment->comment_date);
+
+	if ( $comment ) {
+		if ( ! $date_format ) {
+			$date = mysql2date( get_option( 'date_format' ), $comment->comment_date );
+		} else {
+			$date = mysql2date( $date_format, $comment->comment_date );
+		}
+	} else {
+		$date = '';
+	}
+
 	/**
 	 * Filters the returned comment date.
 	 *
 	 * @since 1.5.0
 	 *
-	 * @param string|int $date    Formatted date string or Unix timestamp.
-	 * @param string     $d       The format of the date.
-	 * @param WP_Comment $comment The comment object.
+	 * @param string|int      $date        Formatted date string or Unix timestamp.
+	 * @param string          $date_format The format of the date.
+	 * @param WP_Comment|null $comment     The comment object.
 	 */
-	return apply_filters( 'get_comment_date', $date, $d, $comment );
+	return apply_filters( 'get_comment_date', $date, $date_format, $comment );
 }
 
 /**
@@ -560,12 +583,12 @@
  * @since 0.71
  * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
  *
- * @param string         $d          Optional. The format of the date. Default user's settings.
- * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date.
- *                                   Default current comment.
+ * @param string         $date_format Optional. The format of the date. Default user's settings.
+ * @param int|WP_Comment $comment_ID  WP_Comment or ID of the comment for which to print the date.
+ *                                    Default current comment.
  */
-function comment_date( $d = '', $comment_ID = 0 ) {
-	echo get_comment_date( $d, $comment_ID );
+function comment_date( $date_format = '', $comment_ID = 0 ) {
+	echo get_comment_date( $date_format, $comment_ID );
 }
 
 /**
@@ -583,8 +606,12 @@
  * @return string The maybe truncated comment with 20 words or less.
  */
 function get_comment_excerpt( $comment_ID = 0 ) {
-	$comment = get_comment( $comment_ID );
-	$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
+	$comment      = get_comment( $comment_ID );
+	$comment_text = ( $comment ) ? $comment->comment_content : '';
+	$comment_ID   = ( $comment ) ? $comment->comment_ID : $comment_ID;
+
+	$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment_text ) );
+
 	$words = explode( ' ', $comment_text );
 
 	/**
@@ -611,11 +638,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $excerpt    The comment excerpt text.
-	 * @param int        $comment_ID The comment ID.
-	 * @param WP_Comment $comment    The comment object.
+	 * @param string          $excerpt    The comment excerpt text.
+	 * @param int             $comment_ID The comment ID.
+	 * @param WP_Comment|null $comment    The comment object.
 	 */
-	return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment );
 }
 
 /**
@@ -629,7 +656,8 @@
  */
 function comment_excerpt( $comment_ID = 0 ) {
 	$comment         = get_comment( $comment_ID );
-	$comment_excerpt = get_comment_excerpt( $comment );
+	$comment_excerpt = ( $comment ) ? get_comment_excerpt( $comment ) : '';
+	$comment_ID      = ( $comment ) ? $comment->comment_ID : $comment_ID;
 
 	/**
 	 * Filters the comment excerpt for display.
@@ -640,7 +668,7 @@
 	 * @param string $comment_excerpt The comment excerpt text.
 	 * @param int    $comment_ID      The comment ID.
 	 */
-	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
+	echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID );
 }
 
 /**
@@ -651,7 +679,8 @@
  * @return int The comment ID.
  */
 function get_comment_ID() {
-	$comment = get_comment();
+	$comment    = get_comment();
+	$comment_ID = ( $comment ) ? $comment->comment_ID : 0;
 
 	/**
 	 * Filters the returned comment ID.
@@ -659,10 +688,10 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` parameter was added.
 	 *
-	 * @param int        $comment_ID The current comment ID.
-	 * @param WP_Comment $comment    The comment object.
+	 * @param int             $comment_ID The current comment ID.
+	 * @param WP_Comment|null $comment    The comment object.
 	 */
-	return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_ID', $comment_ID, $comment );
 }
 
 /**
@@ -702,7 +731,7 @@
 function get_comment_link( $comment = null, $args = array() ) {
 	global $wp_rewrite, $in_comment_loop;
 
-	$comment = get_comment($comment);
+	$comment = get_comment( $comment );
 
 	// Back-compat.
 	if ( ! is_array( $args ) ) {
@@ -718,7 +747,7 @@
 	);
 	$args = wp_parse_args( $args, $defaults );
 
-	$link = get_permalink( $comment->comment_post_ID );
+	$link = ( $comment ) ? get_permalink( $comment->comment_post_ID ) : '';
 
 	// The 'cpage' param takes precedence.
 	if ( ! is_null( $args['cpage'] ) ) {
@@ -742,7 +771,7 @@
 				$cpage = get_query_var( 'cpage' );
 			} else {
 				// Requires a database hit, so we only do it when we can't figure out from context.
-				$cpage = get_page_of_comment( $comment->comment_ID, $args );
+				$cpage = ( $comment ) ? get_page_of_comment( $comment->comment_ID, $args ) : 0;
 			}
 		}
 
@@ -768,11 +797,11 @@
 
 	}
 
-	if ( $wp_rewrite->using_permalinks() ) {
+	if ( $link && $wp_rewrite->using_permalinks() ) {
 		$link = user_trailingslashit( $link, 'comment' );
 	}
 
-	$link = $link . '#comment-' . $comment->comment_ID;
+	$link = ( $link ) ? $link . '#comment-' . $comment->comment_ID : '';
 
 	/**
 	 * Filters the returned single comment permalink.
@@ -782,10 +811,10 @@
 	 *
 	 * @see get_page_of_comment()
 	 *
-	 * @param string     $link    The comment permalink with '#comment-$id' appended.
-	 * @param WP_Comment $comment The current comment object.
-	 * @param array      $args    An array of arguments to override the defaults.
-	 * @param int        $cpage   The calculated 'cpage' value.
+	 * @param string          $link    The comment permalink with '#comment-$id' appended.
+	 * @param WP_Comment|null $comment The current comment object.
+	 * @param array           $args    An array of arguments to override the defaults.
+	 * @param int             $cpage   The calculated 'cpage' value.
 	 */
 	return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage );
 }
@@ -949,7 +978,8 @@
  * @return string The comment content.
  */
 function get_comment_text( $comment_ID = 0, $args = array() ) {
-	$comment = get_comment( $comment_ID );
+	$comment      = get_comment( $comment_ID );
+	$comment_text = ( $comment ) ? $comment->comment_content : '';
 
 	/**
 	 * Filters the text of a comment.
@@ -958,11 +988,11 @@
 	 *
 	 * @see Walker_Comment::comment()
 	 *
-	 * @param string     $comment_content Text of the comment.
-	 * @param WP_Comment $comment         The comment object.
-	 * @param array      $args            An array of arguments.
+	 * @param string          $comment_content Text of the comment.
+	 * @param WP_Comment|null $comment         The comment object.
+	 * @param array           $args            An array of arguments.
 	 */
-	return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
+	return apply_filters( 'get_comment_text', $comment_text, $comment, $args );
 }
 
 /**
@@ -978,9 +1008,9 @@
  * @param array           $args       Optional. An array of arguments. Default empty array. Default empty.
  */
 function comment_text( $comment_ID = 0, $args = array() ) {
-	$comment = get_comment( $comment_ID );
+	$comment      = get_comment( $comment_ID );
+	$comment_text = ( $comment ) ? get_comment_text( $comment, $args ) : '';
 
-	$comment_text = get_comment_text( $comment, $args );
 	/**
 	 * Filters the text of a comment to be displayed.
 	 *
@@ -988,9 +1018,9 @@
 	 *
 	 * @see Walker_Comment::comment()
 	 *
-	 * @param string     $comment_text Text of the current comment.
-	 * @param WP_Comment $comment      The comment object.
-	 * @param array      $args         An array of arguments.
+	 * @param string          $comment_text Text of the current comment.
+	 * @param WP_Comment|null $comment      The comment object.
+	 * @param array           $args         An array of arguments.
 	 */
 	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
 }
@@ -1000,20 +1030,25 @@
  *
  * @since 1.5.0
  *
- * @param string $d         Optional. The format of the time. Default user's settings.
- * @param bool   $gmt       Optional. Whether to use the GMT date. Default false.
- * @param bool   $translate Optional. Whether to translate the time (for use in feeds).
- *                          Default true.
+ * @param string $time_format Optional. The format of the time. Default user's settings.
+ * @param bool   $gmt         Optional. Whether to use the GMT date. Default false.
+ * @param bool   $translate   Optional. Whether to translate the time (for use in feeds).
+ *                            Default true.
  * @return string The formatted time.
  */
-function get_comment_time( $d = '', $gmt = false, $translate = true ) {
+function get_comment_time( $time_format = '', $gmt = false, $translate = true ) {
 	$comment = get_comment();
 
-	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
-	if ( '' == $d )
-		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
-	else
-		$date = mysql2date($d, $comment_date, $translate);
+	if ( $comment ) {
+		$comment_time = ( $gmt ) ? $comment->comment_date_gmt : $comment->comment_date;
+		if ( ! $time_format ) {
+			$time = mysql2date( get_option( 'time_format' ), $comment_time, $translate );
+		} else {
+			$time = mysql2date( $time_format, $comment_time, $translate );
+		}
+	} else {
+		$time = '';
+	}
 
 	/**
 	 * Filters the returned comment time.
@@ -1020,13 +1055,13 @@
 	 *
 	 * @since 1.5.0
 	 *
-	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
-	 * @param string     $d         Date format.
-	 * @param bool       $gmt       Whether the GMT date is in use.
-	 * @param bool       $translate Whether the time is translated.
-	 * @param WP_Comment $comment   The comment object.
+	 * @param string|int      $time        The comment time, formatted as a date string or Unix timestamp.
+	 * @param string          $time_format Time format.
+	 * @param bool            $gmt         Whether the GMT date is in use.
+	 * @param bool            $translate   Whether the time is translated.
+	 * @param WP_Comment|null $comment     The comment object.
 	 */
-	return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
+	return apply_filters( 'get_comment_time', $time, $time_format, $gmt, $translate, $comment );
 }
 
 /**
@@ -1034,10 +1069,10 @@
  *
  * @since 0.71
  *
- * @param string $d Optional. The format of the time. Default user's settings.
+ * @param string $time_format Optional. The format of the time. Default user's settings.
  */
-function comment_time( $d = '' ) {
-	echo get_comment_time($d);
+function comment_time( $time_format = '' ) {
+	echo get_comment_time( $time_format );
 }
 
 /**
@@ -1052,9 +1087,15 @@
  */
 function get_comment_type( $comment_ID = 0 ) {
 	$comment = get_comment( $comment_ID );
-	if ( '' == $comment->comment_type )
-		$comment->comment_type = 'comment';
 
+	if ( $comment ) {
+		$comment_type = ( $comment->comment_type ) ? $comment->comment_type : 'comment';
+	} else {
+		$comment_type = '';
+	}
+
+	$comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID;
+
 	/**
 	 * Filters the returned comment type.
 	 *
@@ -1061,11 +1102,11 @@
 	 * @since 1.5.0
 	 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
 	 *
-	 * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
-	 * @param int 	     $comment_ID   The comment ID.
-	 * @param WP_Comment $comment      The comment object.
+	 * @param string          $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
+	 * @param int             $comment_ID   The comment ID.
+	 * @param WP_Comment|null $comment      The comment object.
 	 */
-	return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
+	return apply_filters( 'get_comment_type', $comment_type, $comment_ID, $comment );
 }
 
 /**
@@ -1609,7 +1650,7 @@
 
 	$comment = get_comment( $comment );
 
-	if ( empty( $post ) ) {
+	if ( ! $post && $comment ) {
 		$post = $comment->comment_post_ID;
 	}
 
@@ -1624,10 +1665,10 @@
 	 *
 	 * @since 4.1.0
 	 *
-	 * @param array      $args    Comment reply link arguments. See get_comment_reply_link()
-	 *                            for more information on accepted arguments.
-	 * @param WP_Comment $comment The object of the comment being replied to.
-	 * @param WP_Post    $post    The WP_Post object.
+	 * @param array           $args    Comment reply link arguments. See get_comment_reply_link()
+	 *                                 for more information on accepted arguments.
+	 * @param WP_Comment|null $comment The object of the comment being replied to.
+	 * @param WP_Post         $post    The WP_Post object.
 	 */
 	$args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
 
@@ -1636,7 +1677,7 @@
 			esc_url( wp_login_url( get_permalink() ) ),
 			$args['login_text']
 		);
-	} else {
+	} elseif ( $comment ) {
 		$onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
 			$args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
 		);
@@ -1647,6 +1688,8 @@
 			esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
 			$args['reply_text']
 		);
+	} else {
+		$link = '';
 	}
 
 	/**
@@ -1654,10 +1697,10 @@
 	 *
 	 * @since 2.7.0
 	 *
-	 * @param string  $link    The HTML markup for the comment reply link.
-	 * @param array   $args    An array of arguments overriding the defaults.
-	 * @param object  $comment The object of the comment being replied.
-	 * @param WP_Post $post    The WP_Post object.
+	 * @param string          $link    The HTML markup for the comment reply link.
+	 * @param array           $args    An array of arguments overriding the defaults.
+	 * @param WP_Comment|null $comment The object of the comment being replied to.
+	 * @param WP_Post         $post    The WP_Post object.
 	 */
 	return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
 }
Index: tests/phpunit/tests/comment/getCommentCount.php
===================================================================
--- tests/phpunit/tests/comment/getCommentCount.php	(revision 40115)
+++ tests/phpunit/tests/comment/getCommentCount.php	(working copy)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group comment
+ */
 class Tests_Get_Comment_Count extends WP_UnitTestCase {
 
 	public function test_get_comment_count() {
Index: tests/phpunit/tests/comment/getCommentExcerpt.php
===================================================================
--- tests/phpunit/tests/comment/getCommentExcerpt.php	(revision 40115)
+++ tests/phpunit/tests/comment/getCommentExcerpt.php	(working copy)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group comment
+ */
 class Tests_Get_Comment_Excerpt extends WP_UnitTestCase {
 	protected static $bacon_comment;
 
@@ -23,6 +26,14 @@
 		$this->assertEquals( 20, count( explode( ' ', $excerpt ) ) );
 	}
 
+	public function test_get_comment_excerpt_with_non_existing_id() {
+		$comment_id = self::factory()->comment->create( array(
+			'comment_content' => self::$bacon_comment
+		) );
+
+		$this->assertEquals( '', get_comment_excerpt( -1 ) );
+	}
+
 	public function test_get_comment_excerpt_filtered() {
 		$comment_id = self::factory()->comment->create( array(
 			'comment_content' => self::$bacon_comment
Index: tests/phpunit/tests/comment/getCommentText.php
===================================================================
--- tests/phpunit/tests/comment/getCommentText.php	(nonexistent)
+++ tests/phpunit/tests/comment/getCommentText.php	(working copy)
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * @group comment
+ */
+class Tests_Get_Comment_Text extends WP_UnitTestCase {
+	protected static $bacon_comment;
+
+	public static function setUpBeforeClass() {
+		parent::setUpBeforeClass();
+
+		self::$bacon_comment = 'Bacon ipsum dolor amet porchetta capicola sirloin prosciutto brisket shankle jerky. Ham hock filet mignon boudin ground round, prosciutto alcatra spare ribs meatball turducken pork beef ribs ham beef. Bacon pastrami short loin, venison tri-tip ham short ribs doner swine. Tenderloin pig tongue pork jowl doner. Pork loin rump t-bone, beef strip steak flank drumstick tri-tip short loin capicola jowl. Cow filet mignon hamburger doner rump. Short loin jowl drumstick, tongue tail beef ribs pancetta flank brisket landjaeger chuck venison frankfurter turkey.
+
+Brisket shank rump, tongue beef ribs swine fatback turducken capicola meatball picanha chicken cupim meatloaf turkey. Bacon biltong shoulder tail frankfurter boudin cupim turkey drumstick. Porchetta pig shoulder, jerky flank pork tail meatball hamburger. Doner ham hock ribeye tail jerky swine. Leberkas ribeye pancetta, tenderloin capicola doner turducken chicken venison ground round boudin pork chop. Tail pork loin pig spare ribs, biltong ribeye brisket pork chop cupim. Short loin leberkas spare ribs jowl landjaeger tongue kevin flank bacon prosciutto.
+
+Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket bacon pork chop. Cupim hamburger pork loin short loin. Boudin ball tip cupim ground round ham shoulder. Sausage rump cow tongue bresaola pork pancetta biltong tail chicken turkey hamburger. Kevin flank pork loin salami biltong. Alcatra landjaeger pastrami andouille kielbasa ham tenderloin drumstick sausage turducken tongue corned beef.';
+	}
+
+	public function test_get_comment_text() {
+		$comment_id = self::factory()->comment->create( array(
+			'comment_content' => self::$bacon_comment
+		) );
+
+		$this->assertEquals( self::$bacon_comment, get_comment_text( $comment_id ) );
+	}
+
+	public function test_get_comment_text_with_non_existing_id() {
+		$comment_id = self::factory()->comment->create( array(
+			'comment_content' => self::$bacon_comment
+		) );
+
+		$this->assertEquals( '', get_comment_text( -1 ) );
+	}
+}
Index: tests/phpunit/tests/comment/metaCache.php
===================================================================
--- tests/phpunit/tests/comment/metaCache.php	(revision 40115)
+++ tests/phpunit/tests/comment/metaCache.php	(working copy)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group comment
+ */
 class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
 	protected $i = 0;
 	protected $queries = 0;
Index: tests/phpunit/tests/comment/wpCountComments.php
===================================================================
--- tests/phpunit/tests/comment/wpCountComments.php	(revision 40115)
+++ tests/phpunit/tests/comment/wpCountComments.php	(working copy)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group comment
+ */
 class Tests_WP_Count_Comments extends WP_UnitTestCase {
 
 	public function test_wp_count_comments() {
