[wp-trac] [WordPress Trac] #30412: get_approved_comments() behaviour change with post_id=0

WordPress Trac noreply at wordpress.org
Thu Nov 20 00:55:36 UTC 2014


#30412: get_approved_comments() behaviour change with post_id=0
--------------------------+-----------------------
 Reporter:  dd32          |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.1
Component:  General       |    Version:
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------
 In [30098] `get_approved_comments()` was made a wrapper of
 `WP_Comment_Query`, this has had a slight backwards compat change.

 Previously, `$post_id` was a required parameter, and if passed a falsey
 value would simply return an empty array (as it'd query for post_id = 0).
 After the change, it now queries for comments on ALL posts, this can very
 easily exhaust system resources if someone was calling the function
 incorrectly.

 Attached is a patch for review, It simply makes $post_id a required
 parameter, and if it evaluates false the function returns an empty array.

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


More information about the wp-trac mailing list