Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#27064 closed enhancement (fixed)

Allow user_id to accept an array of IDs for WP_Comment_Query

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

Description

As the user who submitted this support ticket wanted, it seems perfectly reasonable to me that we should allow an array of user IDs to be passed to the user_id parameter of WP_Comment_Query in order to retrieve comments by multiple users.

I'd propose that the user_id allow either an integer or an array to be passed.

Attachments (5)

27064.patch (731 bytes) - added by mordauk 10 years ago.
Allow user_id to be passed as an array to WP_Comment_Query
27064-2.patch (732 bytes) - added by mordauk 10 years ago.
Refresh patch for spacing
27064-tests.patch (1.5 KB) - added by mordauk 10 years ago.
Basic unit tests for "user_id" parameter of get_comments()
27064-tests-2.patch (1.5 KB) - added by mordauk 10 years ago.
Fixed failed assertions
27064-tests-3.patch (1.1 KB) - added by mordauk 10 years ago.
More concise unit tests, thanks to markjaquith for his feedback

Download all attachments as: .zip

Change History (12)

@mordauk
10 years ago

Allow user_id to be passed as an array to WP_Comment_Query

#1 @nacin
10 years ago

Works for me. We should put a space between IN and (.

Would also be cool if a simple user test ended up in tests/phpunit/tests/comment/query.php.

#2 @nacin
10 years ago

  • Keywords has-patch commit needs-unit-tests added
  • Milestone changed from Awaiting Review to 3.9

#3 @mordauk
10 years ago

Sure thing, I'll upload a new patch in a few minutes.

@mordauk
10 years ago

Refresh patch for spacing

@mordauk
10 years ago

Basic unit tests for "user_id" parameter of get_comments()

#4 @mordauk
10 years ago

Patches updated. I don't have phpunit on this computer so the unit tests are untested (ha), but I think they will work.

I wasn't completely sure on the best way to write the tests for this one, so let me know if you'd prefer to see something different.

@mordauk
10 years ago

Fixed failed assertions

#5 @mordauk
10 years ago

I've now tested and (after updating the patch) confirmed the unit tests pass now.

@mordauk
10 years ago

More concise unit tests, thanks to markjaquith for his feedback

#6 @mordauk
10 years ago

  • Keywords needs-unit-tests removed

#7 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 27258:

Allow user_id to be an array of IDs in WP_Comment_Query.

props mordauk.
fixes #27064.

Note: See TracTickets for help on using tickets.