Skip to:
Content

Ticket #7513: 7513.2.diff

File 7513.2.diff, 1.7 KB (added by dcavins, 14 months ago)

Respect that a dev can force-disable search by passing a search_term of .

  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index d074884cc..95cfad88a 100644
    function bp_total_group_count_for_user( $user_id = 0 ) { 
    38643864 *                                        {@link BP_User_Query}. Default: 'last_joined'.
    38653865 *     @type string   $search_terms       Optional. Search terms to match. Pass an
    38663866 *                                        empty string to force-disable search, even in
    3867  *                                        the presence of $_REQUEST['s']. Default: null.
     3867 *                                        the presence of $_REQUEST['s']. Default: false.
    38683868 * }
    38693869 *
    38703870 * @return bool
    function bp_group_has_members( $args = '' ) { 
    38783878                $exclude_admins_mods = 0;
    38793879        }
    38803880
    3881         $search_terms_default = null;
     3881        /*
     3882         * Use false as the search_terms default so that BP_User_Query
     3883         * doesn't add a search clause.
     3884         */
     3885        $search_terms_default = false;
    38823886        $search_query_arg = bp_core_get_component_search_query_arg( 'members' );
    38833887        if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) {
    38843888                $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] );
    function bp_group_has_members( $args = '' ) { 
    38973901                'type'                => 'last_joined',
    38983902        ) );
    38993903
    3900         if ( is_null( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) {
     3904        /*
     3905         * If an empty search_terms string has been passed,
     3906         * the developer is force-disabling search.
     3907         */
     3908        if ( '' === $r['search_terms'] ) {
     3909                // Set the search_terms to false for BP_User_Query efficiency.
     3910                $r['search_terms'] = false;
     3911        } elseif ( ! empty( $_REQUEST['s'] ) ) {
    39013912                $r['search_terms'] = $_REQUEST['s'];
    39023913        }
    39033914