Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/26/2020 02:11:53 PM (13 months 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.