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

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 23 15:25:47 UTC 2012


#19623: Use Comment API in comments_template, rather than hardcoded SQL
-------------------------------------+------------------------------
 Reporter:  simonwheatley            |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Comments                 |     Version:  3.3
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+------------------------------

Comment (by hardy101):

 scribu,

 Sorry I got twitchy on the version flag.

 You're right - I was trying to create a line-for-line replacement of the
 old SQL queries. simonwheatley's original patch was much more elegant in
 some ways.

 I took the best of his patch and streamlined a few things:

 1) Took out the direct instantiation of a new WP_Comment_Query, instead
 using the layer of abstraction afforded by get_comments().  Cleaner.

 2) Took out filter 'comments_template_args' since 'pre_get_comments'
 already accounts for the ability to modify the arg list passed to
 WP_Comment_Query

 3) Cleaned up the 'where' string concatenation when building the SQL
 query.

 4) Did a check for empty $post__in array when adding " AND comment_post_ID
 IN ($_post__in)" to where clause.  Would cause an SQL syntax error if
 passed an empty array.

 I think this combination effort may be a winner.  See patch 19623-2.diff

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19623#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list