Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/09/2014 01:58:11 PM (12 years ago)
Author:
boonebgorges
Message:

BP_User_Query search_terms should match against user_login and user_nicename in addition to xprofile fields

This changeset changes the search_terms logic in BP_User_Query so that it
matches user_login and user_nicename in the core users table. Then, via filter,
the xprofile component amends the WHERE clause so that search_terms are matched
in the users table OR the xprofile data table.

Clauses have been refactored to subqueries rather than storing the matched
user IDs in PHP, for improved performance.

See #5155

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/testcases/core/class-bp-user-query.php

    r7638 r8087  
    203203
    204204    /**
     205     * @group search_terms
     206     */
     207    public function test_bp_user_query_search_core_fields() {
     208        $user_id = $this->create_user( array(
     209            'user_login' => 'foo',
     210        ) );
     211        xprofile_set_field_data( 1, $user_id, "Bar" );
     212        $q = new BP_User_Query( array( 'search_terms' => 'foo', ) );
     213
     214        $found_user_id = null;
     215        if ( ! empty( $q->results ) ) {
     216            $found_user = array_pop( $q->results );
     217            $found_user_id = $found_user->ID;
     218        }
     219
     220        $this->assertEquals( $user_id, $found_user_id );
     221    }
     222    /**
    205223     * @group exclude
    206224     */
Note: See TracChangeset for help on using the changeset viewer.