Bail early when invalid ID is passed to `get_comment_class()`.

This helps to avoid PHP notices later in the function.

Props walterebert, dipesh.kakadiya, DrewAPicture.
Fixes #33947.
Built from https://develop.svn.wordpress.org/trunk@34454


git-svn-id: http://core.svn.wordpress.org/trunk@34418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-09-23 14:09:26 +00:00
parent 79c3a17060
commit a034a3394a
2 changed files with 6 additions and 3 deletions

View File

@ -433,10 +433,13 @@ function comment_class( $class = '', $comment = null, $post_id = null, $echo = t
function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
global $comment_alt, $comment_depth, $comment_thread_alt;
$comment = get_comment($comment_id);
$classes = array();
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return $classes;
}
// Get the comment type (comment, trackback),
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34453';
$wp_version = '4.4-alpha-34454';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.