Skip to:
Content

BuddyPress.org

Changeset 8290


Ignore:
Timestamp:
04/17/2014 07:08:40 PM (10 years ago)
Author:
boonebgorges
Message:

Reintroduce DISTINCT keyword to BP_Core_User::get_users()

The lack of DISTINCT was causing duplicate entries when joining against the
xprofile fields for the purposes of alphabetical sorts.

Reverts part of r7700. See #5303

Fixes #5550

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r8087 r8290  
    884884        $sql = array();
    885885
    886         $sql['select_main'] = "SELECT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
     886        $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
    887887
    888888        if ( 'active' == $type || 'online' == $type || 'newest' == $type  ) {
  • trunk/tests/testcases/core/class-bp-core-user.php

    r7860 r8290  
    104104    }
    105105
     106    /**
     107     * @expectedDeprecated BP_Core_User::get_users
     108     * @group get_users
     109     * @group type
     110     */
     111    public function test_type_alphabetical() {
     112        $u1 = $this->create_user( array(
     113            'display_name' => 'foo',
     114        ) );
     115        $u2 = $this->create_user( array(
     116            'display_name' => 'bar',
     117        ) );
     118
     119        global $wpdb;
     120
     121        $q = BP_Core_User::get_users( 'alphabetical' );
     122        $found = array_map( 'intval', wp_list_pluck( $q['users'], 'id' ) );
     123
     124        $this->assertEquals( array( $u2, $u1 ), $found );
     125    }
     126
    106127    public function test_get_specific_users() {
    107128        $u1 = $this->create_user();
Note: See TracChangeset for help on using the changeset viewer.