`get_comment_count()` currently increments `awaiting_moderation` when comments are in the trash. This occurs because `case 0:` will match any value passed to `switch` that is a string that isn't specified in the list of cases. This is terrifying.

* Cases for `0` and `1` should be `'1'` and `'0'`
* Add unit tests for `get_comment_count()`. Currently, there are none.

See #33414.

Built from https://develop.svn.wordpress.org/trunk@33806


git-svn-id: http://core.svn.wordpress.org/trunk@33774 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-08-30 02:19:21 +00:00
parent a0e00c0d24
commit e49980bdc1
2 changed files with 3 additions and 3 deletions

View File

@ -375,11 +375,11 @@ function get_comment_count( $post_id = 0 ) {
$comment_count['spam'] = $row['total'];
$comment_count["total_comments"] += $row['total'];
break;
case 1:
case '1':
$comment_count['approved'] = $row['total'];
$comment_count['total_comments'] += $row['total'];
break;
case 0:
case '0':
$comment_count['awaiting_moderation'] = $row['total'];
$comment_count['total_comments'] += $row['total'];
break;

View File

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