Opened 9 years ago
Closed 9 years ago
#35513 closed defect (bug) (fixed)
Ignore all falsy arguments for WP_Comment_Query search argument
Reported by: | danielbachhuber | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
WP_Comment_Query
currently has a strict check for an empty string. When false
or null
is passed to search
, this results in nonsensical SQL:
[18-Jan-2016 13:18:31 UTC] WP_Comment_Query::__set_state(array( 'request' => 'SELECT SQL_CALC_FOUND_ROWS wp_comments.comment_ID FROM wp_comments JOIN wp_posts ON wp_posts.ID = wp_comments.comment_post_ID WHERE ( comment_approved = \'1\' ) AND comment_type IN (\'\') AND (comment_author LIKE \'%%\' OR comment_author_email LIKE \'%%\' OR comment_author_url LIKE \'%%\' OR comment_author_IP LIKE \'%%\' OR comment_content LIKE \'%%\') AND wp_posts.post_type IN (\'page\') ORDER BY wp_comments.comment_date_gmt ASC, wp_comments.comment_ID ASC LIMIT 10',
WP_Comment_Query
should ignore all falsy values.
Discovered in https://github.com/WP-API/WP-API/pull/2052
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Strict comparison was introduced in [15491], at the same time as the search param.
WP_Query
handles 's' in a similar way to what's being proposed here. See [36278], [28623].