Skip to:
Content

BuddyPress.org

Changeset 12329


Ignore:
Timestamp:
01/24/2019 03:17:52 AM (5 years ago)
Author:
boonebgorges
Message:

User query: Ignore falsey values of exclude.

Props espellcaste.
Fixes #8040.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r11886 r12329  
    375375
    376376        // 'exclude' - User ids to exclude from the results.
    377         if ( false !== $exclude ) {
     377        if ( ! empty( $exclude ) ) {
    378378            $exclude_ids    = implode( ',', wp_parse_id_list( $exclude ) );
    379379            $sql['where'][] = "u.{$this->uid_name} NOT IN ({$exclude_ids})";
  • trunk/tests/phpunit/testcases/core/class-bp-user-query.php

    r12244 r12329  
    328328
    329329    /**
     330     * @group exclude
     331     * @ticket BP8040
     332     */
     333    public function test_bp_user_query_should_ignore_empty_exclude() {
     334        $u1 = self::factory()->user->create();
     335        $u2 = self::factory()->user->create();
     336
     337        $q = new BP_User_Query( array( 'exclude' => array() ) );
     338
     339        $found_user_ids = null;
     340        if ( ! empty( $q->results ) ) {
     341            $found_user_ids = array_values( wp_parse_id_list( wp_list_pluck( $q->results, 'ID' ) ) );
     342        }
     343
     344        $this->assertContains( $u1, $found_user_ids );
     345        $this->assertContains( $u2, $found_user_ids );
     346    }
     347    /**
    330348     * @group type
    331349     * @group spam
Note: See TracChangeset for help on using the changeset viewer.