Skip to:
Content

BuddyPress.org

Changeset 12768


Ignore:
Timestamp:
10/26/2020 02:11:53 PM (5 weeks ago)
Author:
boonebgorges
Message:

Declare $get_data = false when calling xprofile_get_field().

The default value of $get_data is true, which means that when calling
xprofile_get_field() with no explicit $user_id, but with a logged-in user,
BP_XProfile_Field::populate() will attempt to fetch the user's data. This
is usually neither intended nor needed, and results in unnecessary database
overhead.

See #8378.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r12765 r12768  
    21322132                    $visibility_level = $user['meta'][ $key ];
    21332133                } else {
    2134                     $vfield           = xprofile_get_field( $field_id );
     2134                    $vfield           = xprofile_get_field( $field_id, null, false );
    21352135                    $visibility_level = isset( $vfield->default_visibility ) ? $vfield->default_visibility : 'public';
    21362136                }
  • trunk/src/bp-members/classes/class-bp-signup.php

    r12752 r12768  
    413413                        $visibility_level = $usermeta[ $key ];
    414414                    } else {
    415                         $vfield           = xprofile_get_field( $field_id );
     415                        $vfield           = xprofile_get_field( $field_id, null, false );
    416416                        $visibility_level = isset( $vfield->default_visibility ) ? $vfield->default_visibility : 'public';
    417417                    }
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r12725 r12768  
    272272
    273273                                    // Load the field.
    274                                     $field = xprofile_get_field( $field->id );
     274                                    $field = xprofile_get_field( $field->id, null, false );
    275275
    276276                                    $class = '';
     
    479479        $field = new BP_XProfile_Field();
    480480    } else {
    481         $field = xprofile_get_field( $field_id );
     481        $field = xprofile_get_field( $field_id, null, false );
    482482    }
    483483
     
    616616    // Handle the deletion of field
    617617    } else {
    618         $field = xprofile_get_field( $field_id );
     618        $field = xprofile_get_field( $field_id, null, false );
    619619
    620620        if ( !$field->delete( (bool) $delete_data ) ) {
     
    651651    }
    652652
    653     $field = xprofile_get_field( $field_id );
     653    $field = xprofile_get_field( $field_id, null, false );
    654654
    655655    $base_url = remove_query_arg( array( 'mode', 'field_id', 'bp_xprofile_delete_field' ), $_SERVER['REQUEST_URI'] ); ?>
  • trunk/src/bp-xprofile/bp-xprofile-caps.php

    r11301 r12768  
    8686    if ( 'bp_xprofile_change_field_visibility' === $capability && 0 === $user_id ) {
    8787        $field_id = bp_get_the_profile_field_id();
    88         if ( $field_id && $field = xprofile_get_field( $field_id ) ) {
     88        if ( $field_id && $field = xprofile_get_field( $field_id, null, false ) ) {
    8989            $user_can = 'allowed' === $field->allow_custom_visibility;
    9090        }
  • trunk/src/bp-xprofile/bp-xprofile-filters.php

    r12694 r12768  
    311311 */
    312312function xprofile_filter_format_field_value_by_field_id( $field_value, $field_id ) {
    313     $field = xprofile_get_field( $field_id );
     313    $field = xprofile_get_field( $field_id, null, false );
    314314    return xprofile_filter_format_field_value_by_type( $field_value, $field->type, $field_id );
    315315}
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r12697 r12768  
    255255    // Instantiate a new field object.
    256256    if ( ! empty( $r['field_id'] ) ) {
    257         $field = xprofile_get_field( $r['field_id'] );
     257        $field = xprofile_get_field( $r['field_id'], null, false );
    258258    } else {
    259259        $field = new BP_XProfile_Field;
     
    526526
    527527    // Use the user's stored level, unless custom visibility is disabled.
    528     $field = xprofile_get_field( $field_id );
     528    $field = xprofile_get_field( $field_id, null, false );
    529529    if ( isset( $field->allow_custom_visibility ) && 'disabled' === $field->allow_custom_visibility ) {
    530530        $current_level = $field->default_visibility;
     
    11001100    }
    11011101
    1102     $field = xprofile_get_field( $field_id );
     1102    $field = xprofile_get_field( $field_id, null, false );
    11031103
    11041104    $enabled = false;
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r12596 r12768  
    768768         */
    769769        if ( ! method_exists( $field, 'get_children' ) ) {
    770             $field_obj = xprofile_get_field( $field->id );
     770            $field_obj = xprofile_get_field( $field->id, null, false );
    771771
    772772            foreach ( $field as $field_prop => $field_prop_value ) {
Note: See TracChangeset for help on using the changeset viewer.