From 3d48e21248a1c1e2de82361c7912729bcc17aa48 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 30 May 2014 19:46:05 +0000 Subject: [PATCH] Fix an error caused by [28604] in `get_comments_number()` unit tests. Props SergeyBiryukov. Fixes #26240. git-svn-id: https://develop.svn.wordpress.org/trunk@28638 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index dafa3a4a5b..3e88fe52dd 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -684,10 +684,11 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) { function get_comments_number( $post_id = 0 ) { $post = get_post( $post_id ); - if ( ! isset( $post->comment_count ) ) { + if ( ! $post ) { $count = 0; } else { $count = $post->comment_count; + $post_id = $post->ID; } /** @@ -698,7 +699,7 @@ function get_comments_number( $post_id = 0 ) { * @param int $count Number of comments a post has. * @param int $post_id Post ID. */ - return apply_filters( 'get_comments_number', $count, $post->ID ); + return apply_filters( 'get_comments_number', $count, $post_id ); } /**