Huge Performance improvement suggestion
-
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 functionbp_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_valueSo 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!
- You must be logged in to reply to this topic.