WordPress.org

Make WordPress Core

Changeset 33806


Ignore:
Timestamp:
08/30/2015 02:18:18 AM (6 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-functions.php

    r33750 r33806  
    376376                $comment_count["total_comments"] += $row['total'];
    377377                break;
    378             case 1:
     378            case '1':
    379379                $comment_count['approved'] = $row['total'];
    380380                $comment_count['total_comments'] += $row['total'];
    381381                break;
    382             case 0:
     382            case '0':
    383383                $comment_count['awaiting_moderation'] = $row['total'];
    384384                $comment_count['total_comments'] += $row['total'];
Note: See TracChangeset for help on using the changeset viewer.