[wp-trac] [WordPress Trac] #27442: WP_Comment_Query conflicts when meta query 'count' is used with with 'group by'

WordPress Trac noreply at wordpress.org
Tue Mar 18 09:21:47 UTC 2014


#27442: WP_Comment_Query conflicts when meta query 'count' is used with with 'group
by'
--------------------------+-----------------------------
 Reporter:  desaiuditd    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 This problem relates to {{{/wp-includes/comment.php}}}, both 3.8.x, trunk
 and later versions are affected.

 Line no. 393 (Version 3.8.1) is {{{ $groupby =
 "{$wpdb->comments}.comment_ID"; }}} is not taking into consideration
 whether {{{ count }}} parameter is being used or not; which results into
 following wrong query output:

 * This is Regualar Meta Query
 {{{
 comment row 1, data
 comment row 2, data
 comment row 3, data
 }}}

 * When count = true is used in the query the class definition only changes
 {{{SELECT *}}} into {{{SELECT COUNT(*)}}} which results into this, since
 there's a group by clause with the comment id.
 {{{
 1
 1
 1
 }}}

 Hence the result will always be either 1 or NULL.

 To resolve this, the {{{GROUP BY}}} clause should be added only when count
 is not passed in the argument.

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


More information about the wp-trac mailing list