Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#27442 closed defect (bug) (duplicate)

WP_Comment_Query conflicts when meta query 'count' is used with with 'group by'

Reported by: desaiuditd's profile desaiuditd Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch
Focuses: Cc:


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.

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.

Attachments (1)

27442.patch (587 bytes) - added by desaiuditd 10 years ago.

Download all attachments as: .zip

Change History (4)

#1 @desaiuditd
10 years ago

  • Keywords dev-feedback has-patch needs-testing added

Attaching the patch 27442.patch

10 years ago

#2 @ocean90
10 years ago

  • Keywords dev-feedback needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Duplicate of #23369.

Please don't open new tickets for the same issue.

#3 @desaiuditd
10 years ago

There was no update on that issue since 2 months. I thought it is left behind because of the old version marked. Is there any specific reason it was not being entertained ?

Note: See TracTickets for help on using tickets.