Skip to:
Content
Pages
Categories
Search
Top
Bottom

Huge Performance improvement suggestion


  • sx1001
    Participant

    @sx1001

    Hi all,

    we have a BP page with around 30 BP-Profile fields configured per user.

    We found that every individual field is queried indiviually twice, resulting in 60 queries for the field sanitization. One query is made to check for allowed HTML, this function
    bp_xprofile_is_richtext_enabled_for_field.

    So I’d have two suggestions for raw performance:
    1st:
    Any way to allow for a hook at the very start of function bp_xprofile_is_richtext_enabled_for_field to disable that check so that I can simply set “false” for all fields globally via Hook? Right now I have to patch bp_xprofile_is_richtext_enabled_for_field() and immediately “return false” right at the beginning. I don’t want HTML anyhow in our fields.

    2nd:
    This filter apply_filters( ‘xprofile_allowed_tags’, $xprofile_allowedtags, $data_obj, $field_id ); queries each and every ProfileField from DB once. At least it can be removed via unhooking.

    This is the call-chain for sanitization for allowed individual tags, it’s this call-chain (from bottom to top):

    BP_XProfile_ProfileData->populate
    BP_XProfile_ProfileData->__construct
    BP_XProfile_Field->get_field_data
    BP_XProfile_Field->populate
    BP_XProfile_Field->__construct
    BPXProfileCFTR\Filters\Xprofile_Kses_Filter->filter
    apply_filters(‘xprofile_allowed_tags’)
    xprofile_filter_kses
    xprofile_sanitize_data_value_before_display
    apply_filters(‘bp_get_the_profile_field_value’)
    bp_get_the_profile_field_value

    So overall, this function runs two queries per field and is the absolute killerblow to performance:
    xprofile_filter_kses().

    A fix would be highly appreciated. At least query all HTML-tag stuff in ONE query for all fields instead of doing it one by one.

    Thanks!

Viewing 1 replies (of 1 total)

  • sx1001
    Participant

    @sx1001

    Ah, what’s more or even worse: This incredibly inperformant function
    xprofile_filter_kses()
    is ran several times during the same pageload on the same data:

    Once for this hook:
    add_filter( 'xprofile_get_field_data', 'xprofile_filter_kses', 1 );

    And yet another time in this call-chain for displaying:
    add_filter( 'bp_get_the_profile_field_value', 'xprofile_sanitize_data_value_before_display', 1, 3 );

    Please have a look!
    Profiles are a huge bottleneck due to this design flaw! Thanks!

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar