[wp-trac] [WordPress Trac] #19623: Use Comment API in comments_template, rather than hardcoded SQL
WordPress Trac
wp-trac at lists.automattic.com
Tue Dec 20 18:07:45 UTC 2011
#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 | Keywords:
---------------------------+-----------------------------
Currently the function {{{comments_template}}} uses hard-coded SQL
queries, rather than {{{WP_Comment_Query}}} or {{{get_comments}}}. There's
a note above the queries saying
[http://core.trac.wordpress.org/browser/tags/3.3/wp-includes/comment-
template.php#L888 /** @todo Use API instead of SELECTs. */].
To replace the queries using the API, the {{{WP_Comment_Query}}} class
will need to be extended to allow querying for comments which are
'''either''' approved '''or''' unapproved ({{{hold}}} status) but by a
particular comment author email and comment author name ''or'' by a
particular {{{user_id}}} to replace these two queries:
* {{{SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND
(comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )
ORDER BY comment_date_gmt}}}
* {{{SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (
comment_approved = '1' OR ( comment_author = %s AND comment_author_email =
%s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt}}}
If we change to use the API, there's also an opportunity to add a filter
for the args, which would be lovely for plugin developers. :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19623>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list