WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#16010 new defect (bug)

get_comments() returns as result (by default) comments that were not approved.

Reported by: mati1000 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0.3
Component: Comments Keywords:
Focuses: Cc:

Description

I see two problems in behavior of "get_comments()" function (wp-includes/comments.php: 180).

  1. The function returns as result (by default) comments that were approved and also comments that were not approved.

I think that this does not fit the standard of all functions in WP that by default return only posts/comments that have been published/approved.

  1. I think that there is no support of cookies of current responder. In other words, a parameter that allows the following functionality does not exist.

comment_approved = '1 'OR (comment_author =% s AND comment_author_email =% s AND comment_approved = '0')
( wp-includes/comments-template.php: 852)

Change History (3)

comment:1 in reply to: ↑ description duck_4 years ago

Replying to mati1000:

  1. The function returns as result (by default) comments that were approved and also comments that were not approved.

I think that this does not fit the standard of all functions in WP that by default return only posts/comments that have been published/approved.

I don't think that this kind of API behaviour will be changed now. Though, yes, it could be argued as inconsistent with get_posts returning published by default.

  1. I think that there is no support of cookies of current responder. In other words, a parameter that allows the following functionality does not exist.

There is better support in 3.1 for this kind of searching, see WP_Comment_Query and the search parameter in wp-includes/comment.php, though haven't tested to see how complicated you can make these.

comment_approved = '1 'OR (comment_author =% s AND comment_author_email =% s AND comment_approved = '0')
( wp-includes/comments-template.php: 852)

That specific query still seems to be unsupported by WP_Comment_Query in 3.1 as get_search_sql only implodes with OR... maybe an operator argument (for future)? This might have been discussed on another ticket when this was being implemented though I haven't searched for it.

comment:2 nacin4 years ago

We can't change the functionality here at this point.

At most, maybe a 'published' flag that makes it obvious.

comment:3 dd324 years ago

  • Milestone changed from Awaiting Review to Future Release
Note: See TracTickets for help on using tickets.