[wp-trac] [WordPress Trac] #48093: get_comment_count() should return an integer for all counts of all statuses

WordPress Trac noreply at wordpress.org
Sat Sep 21 09:55:12 UTC 2019


#48093: get_comment_count() should return an integer for all counts of all statuses
--------------------------+------------------------------------------
 Reporter:  johnbillion   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  2.0
 Severity:  normal        |   Keywords:  needs-patch needs-unit-tests
  Focuses:                |
--------------------------+------------------------------------------
 `get_comment_count()` returns a mixture of integers and numeric strings
 depending on the comment status and count.

 Any status with zero comments is represented by integer 0.
 Any status with more than zero comments is represented by a numeric
 string.
 The `total_comments` and `all` elements are always integers.

 Example:

 {{{
 array(7) {
   ["approved"]            => string(1) "221"
   ["awaiting_moderation"] => int(0)
   ["spam"]                => string(1) "10"
   ["trash"]               => int(0)
   ["post-trashed"]        => int(0)
   ["total_comments"]      => int(221)
   ["all"]                 => int(211)
 }
 }}}

 It should return integers for all statuses for consistency.

 The tests in `Tests_Get_Comment_Count()` should be switched to using
 `assertSame()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48093>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list