[wp-trac] [WordPress Trac] #35513: Ignore all falsy arguments for WP_Comment_Query search argument

WordPress Trac noreply at wordpress.org
Mon Jan 18 15:34:40 UTC 2016


#35513: Ignore all falsy arguments for WP_Comment_Query search argument
-----------------------------+--------------------------------------
 Reporter:  danielbachhuber  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  4.5
Component:  Comments         |    Version:
 Severity:  normal           |   Keywords:  has-patch has-unit-tests
  Focuses:                   |
-----------------------------+--------------------------------------
 `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

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35513>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list