Skip to:
Content

BuddyPress.org

Changeset 10937


Ignore:
Timestamp:
07/06/2016 02:02:37 AM (8 years ago)
Author:
dcavins
Message:

Improve BP_Groups_Group::filter_user_groups().

Add a preceding wildcard to the LIKE search terms statement in
BP_Groups_Group::filter_user_groups(). Before this change, the
function would only find group names and descriptions that started with
the search string.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r10913 r10937  
    507507            $user_id = bp_displayed_user_id();
    508508
    509         $search_terms_like = bp_esc_like( $filter ) . '%';
     509        $search_terms_like = '%' . bp_esc_like( $filter ) . '%';
    510510
    511511        $pag_sql = $order_sql = $hidden_sql = '';
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php

    r10766 r10937  
    614614    }
    615615
     616    public function test_filter_user_groups_normal_search_middle_of_string() {
     617        $g1 = $this->factory->group->create( array(
     618            'name' => 'Cool Group',
     619            'description' => 'This group is for mandocellos and oboes.',
     620        ) );
     621        $g2 = $this->factory->group->create();
     622        $u = $this->factory->user->create();
     623        self::add_user_to_group( $u, $g1 );
     624
     625        $groups = BP_Groups_Group::filter_user_groups( 'cello', $u );
     626
     627        $found = wp_list_pluck( $groups['groups'], 'group_id' );
     628        $this->assertEquals( array( $g1 ), $found );
     629    }
     630
    616631    public function test_filter_user_groups_search_with_underscores() {
    617632        $g1 = $this->factory->group->create( array(
Note: See TracChangeset for help on using the changeset viewer.