From 2d6721dbc9373fadb2a32c7a223526b243fc2015 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 30 May 2014 19:47:14 +0000 Subject: [PATCH] Fix an error caused by [28604] in `get_comments_number()` unit tests. Props SergeyBiryukov. Fixes #26240. Built from https://develop.svn.wordpress.org/trunk@28638 git-svn-id: http://core.svn.wordpress.org/trunk@28456 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index dafa3a4a5b..3e88fe52dd 100644 --- a/wp-includes/comment-template.php +++ b/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 ); } /**