Skip to:
Content

BuddyPress.org

Changeset 9985


Ignore:
Timestamp:
07/02/2015 12:54:28 PM (6 years ago)
Author:
boonebgorges
Message:

Fix SQL syntax error in BP_Friends_Friendship::search_friends().

Props rittesh.patel.
Fixes #6546.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-friends-friendship.php

    r9819 r9985  
    343343            $total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ({$fids}) AND value LIKE %s", $search_terms_like );
    344344        } else {
    345             $sql       = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE %s' {$pag_sql}", $search_terms_like );
     345            $sql       = $wpdb->prepare( "SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE %s {$pag_sql}", $search_terms_like );
    346346            $total_sql = $wpdb->prepare( "SELECT COUNT(DISTINCT user_id) FROM {$wpdb->usermeta} WHERE user_id IN ({$fids}) AND meta_key = 'nickname' AND meta_value LIKE %s", $search_terms_like );
    347347        }
  • trunk/tests/phpunit/testcases/friends/class-bp-friends-friendship.php

    r9819 r9985  
    1212        xprofile_set_field_data( 1, $u2, 'Cool Dude' );
    1313        xprofile_set_field_data( 1, $u3, 'Rock And Roll America Yeah' );
     14
     15        friends_add_friend( $u1, $u2, true );
     16        friends_add_friend( $u1, $u3, true );
     17
     18        $friends = BP_Friends_Friendship::search_friends( 'Coo', $u1 );
     19        $this->assertEquals( array( $u2 ), $friends['friends'] );
     20    }
     21
     22    /**
     23     * @ticket BP6546
     24     */
     25    public function test_search_friends_with_xprofile_inactive() {
     26        $this->deactivate_component( 'xprofile' );
     27
     28        $u1 = $this->factory->user->create();
     29        $u2 = $this->factory->user->create();
     30        $u3 = $this->factory->user->create();
     31
     32        add_user_meta( $u2, 'nickname', 'Cool Dude' );
     33        add_user_meta( $u3, 'nickname', 'Rock And Roll America Yeah' );
    1434
    1535        friends_add_friend( $u1, $u2, true );
Note: See TracChangeset for help on using the changeset viewer.