Skip to:
Content

BuddyPress.org

Opened 6 years ago

Closed 6 years ago

#8040 closed defect (bug) (fixed)

`BP_User_Query` should ignore empty `exclude`

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 5.0.0 Priority: normal
Severity: normal Version:
Component: Core Keywords: good-first-bug has-patch
Cc:

Description

If you pass an empty array (or empty string, or some other falsey value other than false) to the 'exclude' param of BP_User_Query, you end up with malformed SQL. See https://buddypress.trac.wordpress.org/browser/tags/4.1.0/src/bp-core/classes/class-bp-user-query.php?marks=377#L376

This check should be less strict. Empty arrays, in particular, should result in the NOT IN clause being skipped. This is semantically correct ("exclude no one") and is also consistent with the behavior of include.

Attachments (1)

8040.diff (539 bytes) - added by espellcaste 6 years ago.

Download all attachments as: .zip

Change History (3)

@espellcaste
6 years ago

#1 @espellcaste
6 years ago

  • Keywords has-patch added; needs-patch removed

@boonebgorges I added a patch to fix it.

#2 @boonebgorges
6 years ago

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

In 12329:

User query: Ignore falsey values of exclude.

Props espellcaste.
Fixes #8040.

Note: See TracTickets for help on using tickets.