[wp-trac] [WordPress Trac] #19623: Use Comment API in comments_template, rather than hardcoded SQL

WordPress Trac noreply at wordpress.org
Sun Oct 19 19:38:17 UTC 2014


#19623: Use Comment API in comments_template, rather than hardcoded SQL
-------------------------------------------------+-------------------------
 Reporter:  simonwheatley                        |       Owner:
     Type:  enhancement                          |  boonebgorges
 Priority:  normal                               |      Status:  closed
Component:  Comments                             |   Milestone:  4.1
 Severity:  major                                |     Version:  3.3
 Keywords:  has-patch needs-testing 2nd-opinion  |  Resolution:  fixed
                                                 |     Focuses:
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"29965"]:
 {{{
 #!CommitTicketReference repository="" revision="29965"
 Use the comment API rather than direct SQL queries in
 `comments_template()`.

 `comments_template()` is used by most themes to display a post's comments.
 It
 shows all comments that have been approved, and also shows all pending
 comments
 by the current visitor (as determined by the comment cookies). However,
 the
 comments API previously had no way of querying for "all comments that are
 either approved, or are unapproved but written by foo at example.com". The
 workaround was a direct SQL query: uncached, not subject to the same
 filters as
 other comment queries, and just generally icky.

 The new `include_unapproved` parameter for `WP_Comment_Query` accepts an
 array
 of user IDs or email addresses. Pending comments associated with users in
 this
 array will be included in query results, regardless of the value of the
 'status'
 parameter. In `comments_template()`, we leap from direct SQL queries to
 `get_comments()` plus `include_unapproved', striving to put right what
 once
 went wrong.

 Props boonebgorges, simonwheatley, hardy101, jesin.
 Fixes #19623.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/19623#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list